## Infosys Interview Question for Software Engineer / Developers

• 0

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

1) break array in decreasing order sets
2) find minimum in each set.

{5,4,2} {7,9,6}

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

start ad the end of the array and set current = a[n-1]
iterate backwards
while a[i] > current : decrement
if(a[i]< current : current = a[i]

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

i don't think your logic works for 5,4,2,7,9,6,10

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

I dont get it.. Why is the solution wrong for the ur test case ?

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

start ad the end of the array and set current = a[n-1]
iterate backwards
while a[i] > current : decrement
if(a[i]< current : current = a[i]

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

start ad the end of the array and set current = a[n-1]
iterate backwards
while a[i] > current : decrement
if(a[i]< current : current = a[i]

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

bubble sort or selection sort in reverse direction?

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

Dont tell me infosys asks such questions.. it is a dumb company and if you get there, you ll be working with a bunch of technically incompetent people

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

IQ test is also a way to examine the ability of employees.
As you can see, not all people in this thread know the correct solution.

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

@ftfish do u have right ans?

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

Are you sure only decrement is allowed? Not even a single comparison?

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

Ma k lode... Bhenchod

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

n is the number of elemnets.
c=a[n-1];
i=n-2;
while(i!=-1){
if(a[i]>c)
{
a[i]=c;
}
if(a[i]<c)
{
c=a[i];
}
i--;
}

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

its working....

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

Either the question is wrongly asked or formatted because if the only operation can be decrement then no logical operations can be done as well. I guess the intention was without swap operation what would be the ideal way to sort it, which is quite straightforward.

Just retrieve the last element from the list and go on reducing all numbers until it equals to that. If at any moment of time the number is lower than the limit to which it has to reduced, then the new limit is set as the present number. Iterate through the loop solution in O(n).

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.

### 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.