Engineer Interview Questions | Glassdoor.co.in

# Engineer Interview Questions

131,197

engineer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

1 Apr 2010

### Software Development Engineer at Microsoft was asked...

12 Jul 2013
 out of 25 horses select the fastest three in minimum number of races where in each race there would be exactly five horses.10 Answers6 races i thinkit could be 6 races... first five races taking 5 horses each,and then the 6th ace taking the 1st horse of each of the previous race,den select the fastest three among them.would be 5 races if a stop watch is given..... however solutions given before are wrong since the horse coming 2nd in the first race might be faster than the horses that come first in the subsequent race :) hence we have to assume that a timer is providedShow more responsesumesh no timer has been provided and it would be 7 races :)11 races First 5 races taking 5 horses in each race. Next 5 races taking in each race horses which have come first, horses which have come second, third, fourth and fifth....... Final 11th race out of 5 which have won in second set of races to find fastest 36 Race would be wrong answer. What if in one group all the 5 horses are fastest of all others. Then from first round of 5 races we might lose those 2nd and 3rd ones. My answer is also 11 Races.Round one - 5 Races -------------------- Including all 25 horses. 5 each race. Left with -> 15 horses [Take 1st,2nd & 3rd from each race. Which would be total of 5*3=15 horses.] Round two - 3 Races [ Grouping any 5 of 15 horses left] ------------------- Left with -> 9 horses [Take 1st,2nd & 3rd from each race. which would be total of 3*3=9 horses.] Round three - 1 Race. ---------------- Take any 5 horses of 9 horses left Left with -> 7 horses 3 (1st 2nd and 3rd) + 4 (remaining ones) = 7 horses Round four - 1 Race. ---------------- Take any 5 out of 7 Left with -> 5 Round Five - 1 Race ---------- Race of 5 horses left7 races: Split the 25 into 5 groups and make them race, this would be 5 races. Take the fastest horse of each group and make them race (6th race). Let's label the initial group of the top 3 horses of the 6th as a, b, c. The possible candidate for the 3 fastest are: a[1], a[2], a[3], b[1], b[2], c[1] We just need one last race to determine the top, the race would be between a[2], a[3], b[1], b[2], c[1]. The final result is a[1] then the top 2 of the 7th race.Easy: Correct answer is 11 but much easier method: 1. One race among 5 horses to find the fastest 3. 20 horses left not raced yet. 2. Now keep the 3 fastest horses you found and add two other horses out of 20 horses left to the race, again select the fastest 3. 3. Keep doing this for all 20 horses by selecting 2 of the horses left to race against the fastest 3 always. 1 race (to find the fastest 3) + 10 races (20/2 races to test all other 20 horses) = 11 racesConstant Time - 7 Races 5 Races among 5 each. 6th Race for all third place holders 7th Race for Winner of sixth race +two people who defeated him in 1st race + two people who defeated the second place winner in 6th race. Best Case - 6 Races (3 place winner of 1st race against other 20 and he wins all the time) Worst Case - 11 Races( Make the fastest 3 of each race run against the other 2 each time)

28 May 2015

### Java Developer at WebKul was asked...

9 Oct 2016
 Write a program for odd input the pattern output will as below n=1 *-* n=3 ***** *** *---* *** *****11 Answersimport java.util.Scanner; public class Pattern{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=n;i>=2;i--){ for(int j=1;j<=2*n-(i-1);j++){ System.out.print(" "); } for(int k=1;k<=2*i-1;k++){ System.out.print("*"); } System.out.println(); } for(int i=1;i<=n-1;i++){ System.out.print(" "); } System.out.print("*"); for(int i=1;i<=n;i++){ System.out.print("-"); } System.out.print("*"); System.out.println(); for(int i=2;i<=n;i++){ for(int j=1;j<=n-i;j++){ System.out.print(" "); } for(int k=1;k<=2*i-1;k++){ System.out.print("*"); } System.out.println(); } } }import java.util.*; class Pattern { public static void main(String arr[]) { Scanner input=new Scanner(System.in); System.out.print("enter the "); int n=input.nextInt(); int p=n; for(int i=1;i=1;j--) { System.out.print("*"); } System.out.print(" "); p--; } for(int k=1;k<=n;k++) { System.out.print("_"); } System.out.print(" "); for(int m=1;m<=n;m++) { for(int l=1;l<=2*m-1;l++) { System.out.print("*"); } System.out.print(" "); } } }code for c language #include #include int main() { int n=10,i,j,k,l,m,o; for(i=1;i<=n;i++) { for(j=1;j<=n+i;j++) { if(i==n) { for(k=1;k<=n-1;k++) printf(" "); printf("*"); for(m=1;m<=n;m++) printf(" "); // printf("*"); break; } printf(" "); } for(o=1;o<=2*(n-i)+1;o++) printf("*"); printf("\n"); } for(i=1;iShow more responsesimport java.util.Scanner; class New3 { public static void main(String ... args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); for(int j=n,p=1;j>=2;j--,p++) { for(int i=1;i<=n+p;i++) System.out.print(" "); for(int k=1;k<=2*j-1;k++) System.out.print("*"); System.out.println(""); } for(int i=1;i<=n-1;i++) System.out.print(" "); System.out.print("*"); for(int i=1;i<=n;i++) System.out.print("-"); System.out.print("*"); System.out.println(""); int q=n-2; for(int j=2;j<=n;j++) { for(int i=1;i<=q;i++) System.out.print(" "); q--; for(int k=1;k<=2*j-1;k++) System.out.print("*"); System.out.println(""); } } }import java.util.Scanner; public class Webu { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("enter the no"); int n=sc.nextInt(); for (int i = n; i >1; i--) { for(int j=1;j1){ for (int l =1 ; l <=2*i-1; l++) { System.out.print("*"); } System.out.println(" "); } } } }import java.util.Scanner; public class webu { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("enter the no"); int n=sc.nextInt(); for (int i = n; i >1; i--) { for(int j=1;j1){ for (int l =1 ; l <=2*i-1; l++) { System.out.print("*"); } System.out.println(" "); } } } }import java.util.Scanner; public class webu { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("enter the no"); int n=sc.nextInt(); for (int i = n; i >1; i--) { for(int j=1;j1){ for (int l =1 ; l <=2*i-1; l++) { System.out.print("*"); } System.out.println(" "); } } } }import java.util.Scanner; public class Pattern { public static void main(String ... args){ Scanner sc =new Scanner(System.in); int n=sc.nextInt(); for(int i=0;iimport java.util.Scanner; class Pattern2 { public static void main(String a[]) { System.out.print("Enter the Number "); Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i0;j--) { System.out.print("*"); } System.out.println(); } for(int i=0;ifor swift answer func designPattern6(number:Int){ for i in 1...((number * 2) - 1){ if i%2 == 0{ print("") }else{ for j in 1...((number * 2) - 1){ if j >= (((number * 2) + 1) - i)/2 && j <= ((number * 2) - i){ print("*", terminator: "") }else{ print(" ", terminator: "") } } } print("") } }n=int(input()) for i in range(n): if(n==1): print("* "*(n+1)) elif(n==3): print( " "*i+"*"*(2*n-1-2*i)) else: print(" ") for i in range(n): if(n==3): print(""*(i+1)+"*"*(n+2*i-2))

### Java Developer at Naaptol was asked...

22 Dec 2017
 written test on basic java you can crack if you are average concept in java.10 AnswersBut what is the need of exam no result came 2 months have passed i suggest never go and waste your time.you are right . I have never seen any interview experience that got job offer . at every end of year they have walkin drive . Thats look suspicious . At everytime when you go for interview they ask for reference. It might be true that they hire people who have strong refrencewhat was date of walkin in pune ??Show more responsesThere is no way to communicate with them..I tried sending mail to Hemant Jog...bt couldn't ..it says the email account you tried to reach is disabled.something is fishy about this company....not at all trustworthy company.dont attend any walkin drive.they don't give a sht.Yes I got call. May be they call only those people who cracks Aptitude They may have high cut off.Why aren't they answering our calls n mails.....As far as aptitude is concerned.... There isn't any transparency whether they r selecting on scores or through reference.....make everyones results public..so we'll come to know if they have actually considered our apti results or notI attended third round.. Anyone got call for third round??When you attend the 3rd round and when you gave the 2nd roundWhen you gave the 2nd round and 3rd round?

23 May 2016

### Senior Software Engineer at Amazon was asked...

13 Oct 2012
 You are given a fixed number of 5 rupee, 10 rupee, 20 rupee and 50 rupee stamps. Now given an amount for sending a parcel, you should design an algorithm to come out with the minimum number of stamps that should be used for attaining that amount. For example, if the parcel costed 30 rupees, it could be attained using one 20 rupee stamp and one 10 rupee stamp OR using three 10 rupee stamps OR using one 20 rupee stamp and two 5 rupee stamps OR using one 10 rupee stamp and four 5 rupee stamps OR using two 10 rupee stamps and two 5 rupee stamps. However, the minimum number of stamps is the case of one 20 rupee stamp and one 10 rupee stamp where only two stamps are used. The case where no solution is possible should also be handled, for example, a parcel amount of exactly 33 rupees cannot be attained.9 AnswersThe solution is attained using dynamic programming. The basic idea is that the minimum number of stamps used for attaining an amount x, is 1+minimum of (minimum number of stamps for attaining x-5, minimum number of stamps for attaining x-10, minimum number of stamps for attaining x-20,minimum number of stamps for attaining x-50). You can try to solve this first by assuming that an unlimited number of 5 rupee, 10 rupee, 20 rupee and 50 rupee stamps are available. And then you can take into account that only a fixed number of these stamps are available.And what is the time involved to get this done? I really liked the question.Simple to read but involves good amount of logic. I ve written down the algorithm but i believe i took more time than i initially thought i would take.I understand what the interviewer is trying to test and I know how to solve it, but what about more realistic scenario where parcel postage cost would be beyond given values like 3 units of currency or 37 units of currency.Show more responsesIn this specific case, dynamic programming is overkill. There's a better optimal substructure here: The stamp with greatest value less than parcel cost minus stamp values already committed minimize the total of stamps.1. find the stamp <= cost from highest stamp cost 2. num of found_stamp = found_stamp/cost, rem_stamp = found_stamp % cost 3. Do 1, then 2 until rem_stamp ==0 (done) or rem_stamp < least stamp available (not possible case)In the previous ans, after step 3 if rem_stamp !=0, go back to step 1, find next_stamp < cost (but smaller than value of found_stamp in previous iteration)i=0; boolean solPossible = false; do { if(cost % notes[i] == 0) solPossible = true; else i++; } while(!solPossible && (ivoid sendParsal(int cost) { int[] avlstm={50,20,10,5}; int i=0; while(cost>=5) { while(cost>=avlstm[i]) { System.out.println(avlstm[i]); cost=cost-avlstm[i]; } i++; } if(cost!=0) { System.out.println("Solution not possible."); } }void Foo(int cost) { if (cost % 5 != 0) Console.WriteLine("Not possible"); else if (cost stampCosts = new List() { 50, 20, 10, 5 }; int count = 0; while (cost > 0) foreach (int stampCost in stamptCosts) if (cost >= stampCpst) { cost -= stampCost; Console.WriteLine("Stamp: " + stampCost); count++; break; } } Console.WriteLine("Count: " + count); }

3 Dec 2012
 Can't disclose the exact question because of NDA, but here's some food for thought: 3 can be written as 1+1+1, 1+2, 2+1 4 can be written as 1+1+1+1, 1+1+2, 2+2, 1+2+1, 2+1+1, 3+1, 1+3 Given an integer, how many possible expressions exist? (1+2 and 2+1 are different)8 AnswersThere are total 2 ^(n-1)-1 expressions exist for any integer to be written on the basis of integers < the given Integer. Like for n=3, total 2^(3-1)-1= 3 expressions. For 4, 7 expressions exist and so on.Nof(1) = 0 f(2) = 1 f(n) = Σf(i) + (n-1), where i = 1 to n-1, n>2Show more responsesAder Lee: Shouldn't it be: f(n) = Σf(i) + (n-1), , where i = 1 to n-2, n>2 (i ranges from 1 to n-2, not n-1)f(1) = 0 and f(i) = i - 1 + sum_{i = 0}^{i - 1} f(i) Writing it down helps to find the sum: f(1) = 0(0) f(2) = 1 + 0(1) f(3) = 2 + 1 + 0(3) f(4) = 3 + 3 + 1 + 0(7) f(5) = 4 + 7 + 3 + 1 + 0(15) The first term(i - 1) equals the number of second terms and the second terms are the sum of 2 powers - 1 from 0 to (i - 2) so f(i) = 2^{i - 1} - 1Also there is a neat normal form to generate all variations. For the sake of simplicity I show it for i = 4: Start from 1 + 1 + 1 + 1 and for j in 1 to i - 1 add together j and (j + 1) and write down the numbers and mark the added number in the next iteration. | | | 2 + 1 + 1 1 + 2 + 1 1 + 1 + 2 From the marked numbers to (last - 1) run j and do the same as before. The first generates 2 more, the second 1 more and the last one none. gen by first | | 3 + 1 2 + 2 gen by second: | 1 + 3 We could also generate the one element sum(4) from the first one but it's not needed in the problem. Also this representation looks nicer in a tree form but I can only type text here.The marks moved to the begining of the rows since the forum probably has some nice mangling algorithm. I hope you can figure out how the normalisation works. Might post some python code which does this later.a coin change problem with little modification will do .

### Software Development Engineer In Test (SDET) at Microsoft was asked...

12 Jul 2012
 Data structures and Algorithms related2 AnswersIam readyplz tell me which type of question put up in interview