Adobe Interview Question for Software Engineer / Developers






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

Where this ques was asked ... in Blore or Noida ...... & you have applied for which post ....... pls reply

- Anonymous May 19, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

that doesnt matter while answering the question, does it?

- Anonymous May 19, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

LOL :)

- Anonymous January 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

public class ShareMax {

public static void main(String[] args)
{
int[] a={8,4,3,6,45,10,87,32,2};
int bestMax=0;
int bestMin=0;

int diff=0;
int max=a[0];
int min=a[0];

int i=0;
int len=a.length;
while(i<len)
{
if(a[i]>max)
{
max=a[i];
bestMin = min;
bestMax=max;
diff=max-min;
}
else
{
if(a[i]<min)
min=a[i];
}
i++;
}

System.out.println(bestMax+" "+bestMin);
}
}

- Anonymous May 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I will write psuedo code

indexofmin = 0;
for(i=0 to n; i++)
    if(a[i] < a[min]) i = min;
    if(a[min] < a[n-i-min]) return;

- Abhi May 19, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

No.

- Anonymous May 19, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This solution is wrong try this case 5 3 4 1 3 2 6 3 2

- Anonymous May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

#include<iostream>
using namespace std;

void findMaxDistanceOfIndices(int* inArray, int size)
{
   if (size <= 0)
   {
      cout << "Empty array!" << endl;
      return;
   }

   int maxStartIndex = 0;
   int maxEndIndex = 0;
   int maxDistance = -1;

   int curStartIndex = 0;

   for (int i = 0; i < size; i++)
   {
      if (inArray[i] <= inArray[curStartIndex])
      {
         curStartIndex = i;
      }
      else
      {
         if (i - curStartIndex > maxDistance)
         {
            maxStartIndex = curStartIndex;
            maxEndIndex = i;
            maxDistance = i - curStartIndex;
         }
      }
   }

   if (maxDistance < 0)
   {
      cout << "universally decreasing array! no answer found" << endl;
      return;
   }

   cout << "start index: " << maxStartIndex << " end index: " << maxEndIndex << endl;
   cout << "max distance: " << maxDistance << endl;   
}

int main (int argc, char* argv[])
{
   int size = 9;
   int array[] = {5, 3, 4, 1, 3, 2, 6, 3, 2};

   findMaxDistanceOfIndices(array, size);

   return 0;
   
}

- xyz May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

i think answer there shud be 6. start index 0 , end index 6.
your sol returns 5.
it returns wrong answer for 5,3,4,7 case also.

- ktr May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

See solution posted by celicom on CC question?id=9064656

- Googler May 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can u give link to celicom?

- ktr May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I doubt it can be solved in O(n).......

- wfchiang May 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

You're wrong to doubt. See above.

- Anonymous May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Take an array from 1 to n,like B[1...n]
q=0;
for i=1 to n
if a[i] < a[i+1]
q++;
else
if q>0
B[j++]=q;
q=0;

Maximum element in B will be max of j-i

- Rashid May 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@xyz..ur solution is wrong.read the question properly and after that move towards solution.

- sk June 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<conio.h>
int main()
{
int arr[15]={110,5,5,7,6,6,6,4,4,4,3,-1,1,1,4};
int i,j,a,b;
i=0;
j=14;
while(i<j)
{
if(arr[i]<arr[j])
break;
else if(arr[i+1]<arr[j])
i++;
else if(arr[j-1]>arr[i])
j--;
else
{
i++;
}

}
a=0;
b=14;

while(a<b)
{
if(arr[a]<arr[b])
break;
else if(arr[a+1]<arr[b])
a++;
else if(arr[b-1]>arr[a])
b--;
else
{
b--;
}

}

if((j-i)<(b-a))
{
i=a;
j=b;
}


printf("%d %d",i,j);
}

- k.saluja June 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The solution is not correct: try int arr[]={110,99,97,5,5,7,6,6,6,4,4,4,3,-1,1,1,4};
The problem with it is that j>=size of array-2 and a<=1, so if answer lies somewhere in between [2..size of array-3], it cannot find it.

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

@k saluja : it having O(n^2) complexity... try to make different one..!!

- Naveen June 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/* For a given array arr[], returns the maximum j – i such that
arr[j] > arr[i] */
int maxIndexDiff(int arr[], int n)
{
int maxDiff;
int i, j;

int *LMin = (int *)malloc(sizeof(int)*n);
int *RMax = (int *)malloc(sizeof(int)*n);

/* Construct LMin[] such that LMin[i] stores the minimum value
from (arr[0], arr[1], ... arr[i]) */
LMin[0] = arr[0];
for (i = 1; i < n; ++i)
LMin[i] = min(arr[i], LMin[i-1]);

/* Construct RMax[] such that RMax[j] stores the maximum value
from (arr[j], arr[j+1], ..arr[n-1]) */
RMax[n-1] = arr[n-1];
for (j = n-2; j >= 0; --j)
RMax[j] = max(arr[j], RMax[j+1]);

/* Traverse both arrays from left to right to find optimum j - i
This process is similar to merge() of MergeSort */
i = 0, j = 0, maxDiff = -1;
while (j < n && i < n)
{
if (LMin[i] < RMax[j])
{
maxDiff = max(maxDiff, j-i);
j = j + 1;
}
else
i = i+1;
}

return maxDiff;
}

- SachinGuptaMNNIT June 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Naveen ,

Pls explain how it is o(n2).

I think it is o(2n).

- k.saluja June 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SachinGuptaMNNIT's algorithm takes 4n time in worst case that eventually becomes O(n). Good solution.

- Shivendra Tiwari July 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

StartIndex = A[ 0];
EndIndex = A[1];
Max = abs( a[ 1] - A[ 0] )

for(i= 2: i < limit ; i++)
{
if (a[ StartIndex] > a[ i]) {

StartIndex = i;
}
elseif (abs(a[i] - a[StartIndex]) > max) {

EndIndex = i;


}
max = abs(A[EndIndex] - A[ StartIndex]);
}
}
printf("%d %d %d",StartIndex, EndIndex, Max);

- Anil August 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int maxji(int [] a){
          int l = a.length;
          int i,j,min, max;
          max = j = l-1;
          min = i = 0;
          while(i<l){
                    if ( a[i]<a[min])
                                        min =i;
                    if(a[j]>a[max])
                                        max=j;
                    if(a[min]<a[max])
                                        return max-min;
                    j--;
                    i++;
          }
          return 0;
}

- msharma December 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

0 when all numbers are equal

- msharma December 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

int a[] ={1,-1,8,3,8,-1};
ur code fails

- vinit February 13, 2012 | 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