Adobe Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

what are you, nuts? you yourself posted the solution then what are you asking?

- Mr.4342 July 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Also where is the sub array? How would I know where sub array starts and ends?

- prabhat246 July 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

also why do you think that maxsum will be >=0. think of a list with all negatives. then it should return smallest negative in that list.

- prabhat246 July 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int maxSubArraySum(int a[], int size)
{
int max_so_far = a[0], max_ending_here = 0;
int i;
for(i = 0; i < size; i++)
{
max_ending_here = max_ending_here + a[i];
if (max_so_far < max_ending_here)
max_so_far = max_ending_here;

if(max_ending_here < 0)
max_ending_here = 0;
}
return max_so_far;
}

- srirupesh@gmail.com July 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

this will work for all the cases.
u can juss put one check that arraysize>=1 where it can fail.

- srirupesh@gmail.com July 22, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

int _tmain(int argc, _TCHAR* argv[])
{
int array[] = {80,18,-56453,53,14,90,80,-70,100,105};
int n = sizeof(array)/sizeof(int);

int max_sum=0;
int sum=0;

for(int i = 0; i < n; i++)
{
//if (sum+array[i]>=max_sum) {sum=sum+array[i]; max_sum=sum;}
if (array[i]+array[i+1]>=max_sum) {sum=array[i]+array[i+1]; max_sum=sum;}
else sum=0;
}

std::cout<< max_sum;
getchar();
return 0;
}

- Anonymous August 13, 2013 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More