Engineering Interview Questions | Glassdoor.co.in

# Engineering Interview Questions

77,156

Engineering interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

9 Jul 2012

### Applications Developer at Oracle was asked...

10 Sep 2011
 Tell me a palindrome date before 10-02-2001 (mm-dd-yyyy)7 Answersi got it to be in the 14 th century ...12-31-132109-31-1390Show more responsesSorry it should be 08-31-138010-01-1001how can the month no. will be more than 12 i think the answer should be 29-11-1192 :) correct me if i am wrong.....U r wrong. Mmddyyyy

### Software Engineer at SAP was asked...

7 Dec 2011
 A boy goes to his grandmother’s house. There he either does yoga in the morning / plays tennis in the evening / does neither. However he does not do both on the same day. We know that 22 days he did either 1 activity. 24 mornings he did nothing. 12 evenings he did nothing. How many min days did he stay there to have done this?6 Answers29 days. I used a brute force approach to solve. We know that he stayed a minimum of 24 days (from the question). If he stayed for 25 days can all the conditions be satisfied. If not, what about 26 days and so on ..It's 12 days tennis, 12 days nothing...24 daysit's 29 days Tennis + Yoga = 22 Yoga + nothing = 24 Tennis + Nothing = 12Show more responsesit's 24 days 22(10+12) plays Tennis 2 Nothing 22+2 =24 Morning Rest so total 22+2 =24days(MIN) he stay in grandmothers Home.It's 29 Y: Yoga T: Tennis N: Neither on one day So we get three equations: 1. Y+T=22 2. T+N=24 3. Y+N=12 We are able to conclude: Y=5, T=17, N=7. Hence the min days: 5+17+7=29 days24 is wrong from equations formed ..we know that he stayed for 29 days. 22 day he does either yoga or plays tennis 24 morning he does nothing i.e. he play either tennis or does nothing 12 evening he does nothing i.e. he does yoga or nothing y+t=22 t+n=24 y+n=12 hence y=5,t=17,n=7 there fore he stayed for 29days

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

2 Feb 2012
 Puzzle: There are 25 horses and 5 lanes for conducting a race among them. In a minimum of how many races, would be able to find out the 3 fastest horses among them? Assumption: Speed of horses are consistent enough across races.7 AnswersAnswer: 76 because 5 races req to find 5 fastest and 1 race to determine the top 3 out of the 5 fastest7Show more responses65, just because its speed is consistent between races, so we need note down time taken by all the horses, for this 5 races needed ( 5 lanes and 25 horses ). From the list identify top 3, thats simple!1 race with of 3 horses10

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

19 Sep 2010
 if there are 6 people in a team, how many handshakes will be there7 Answers15There will be 30 hand shakes. In total we have 6 people, so it will be 6 * (6-1) (i.e 1 person will shake hands with 5 people)15 A | B | C| D | E | F | A will perform 5 B will perform 4 C will perform 3 D will perform 2 E will perform 1 F ultimately hand shakes with everyoneShow more responses6c2==6!/(2!*4!)=15lets consider A,B,c,d,e,f so a shakes hand with the other 5 ..b with oter 4 and so on so at last 5+4+3+2+1=1515 people handshakes at a time you have given 6 person first of all the peoples is arranged in row 6 number people have an 5 option for handshakes after that 6 number person out then total number of people 5 again....again....same procedure apply.......Each one will shake hand 5 times, 6x5 -> 30 times

29 Jul 2009

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

26 May 2012
 Find count of unique characters in a given string4 AnswersWhat kind of characters in the string? Assuming ASCII characters, total 256. Array should be a good choose. int uniqueCount(string str){ if(str.size()<2) return str.size(); int charNum[256]={0}; // initialized to zero //counting concurrency for(int i=0; ihere are two ways of attacking this: (1) sort the chars, then walk the list incrementing a count any time you hit a different char (2) take advantage of the fact that there are at most 256 ASCII characters, with values 0 to 255, so build a 256 sized array to hold all possible chars, then as you walk the list, increment the corresponding array entry holding a matching char. first approach: /* sort the string */ for (int i=0; ipublic void counter(String g) { int count; for (int i = 'a' ; i<='z' ; i++){ count = 0; for (int a = 0; aShow more responsesUsing single iteration :) ..... int map[256]={0}; //initialise map to 0 int count=0; string a="abcabnaabcabaccacbbbqf"; for(int i=0;i

### Support Engineer at Flipkart was asked...

2 Jun 2012
 Find the second maximum element in an unsorted array of integers, using single for loop.6 AnswersSolution One: int min = 0; int secondmin = 0; if(array[0] < array[1]) { min = array[0]; second_min = array[1]; } else { min = array[1]; second_min = array[0]; } for(i=3; i#include int main() { int a[]={1,5,7,5,8,2,9,2,5,9}; int max,max2; int i; max=max2=a[0]; for(i=1;imax) { max2=max; max=a[i]; } else if(a[i]max2) { max2=a[i]; } } printf("%d",max2); return 0; }int main() { int a[]={10,1,3,5,11,8,9,6}; int max,max2; if(a[1]>a[0]) { max=a[1]; max2=a[0]; } else { max=a[0]; max2=a[1]; } for(int i=2;imax2) { max2=a[i]; if(max2>max) { max2=max; max=a[i]; } } } cout<Show more responses#include int main(){ int A[]={1,5,7,5,8,2,9,2,5,9}; int i,temp,max1=0,max2=0,n=(sizeof(A))/(sizeof(A[0])); for(i=0;imax2){max2=A[i];} } printf("\n1st Maximum Element: %d",max1); printf("\n2st Maximum Element: %d",max2); return 0;}use strict; use warnings; my @arr = (1,3,4,2,5); @arr = reverse sort @arr; print \$arr[1];#include using namespace std; int main() { int arr[10]; for(int i=0;i>arr[i]; } int max,max2;max=max2=arr[0]; for(int i=1;i=max) max=arr[i]; if(arr[i]>=max2 && arr[i]!=max) max2=arr[i]; } cout<

### Software Engineer at Philips was asked...

5 Jun 2012
 There are 100 balls out of which 99 are of the same weight but one is heavier. In how many minimum attempts you can find the heavier ball?7 Answers5The obvious way is to break them up in two groups, and weigh those against each other. Choose the heavier group and repeat. If there is an odd number, add one ball from a previous weigh. Each side will contain the following in consecutive weighs : 50 , 25, 13, 7, 4, 2, 1. so 7 weighs in total. A less obvious way would be to divide each group in to 3 groups. Weigh two against each other. If one is heavier choose that group and continue. If both sides are equal, then the heavier ball is in the group that wasn't weighed. The largest group in each weigh in the WCS - 34, 12, 4, 2, 1 - so 5 weighs.5Show more responsesMinimum would be 2 attempts.... So you have 100 balls and only 1 ball weighs different from the rest of the 99. Split the 100 balls into two groups. One group with 49 balls and the other with 49 balls. Weight those two groups and we are assume that they will be balanced on a scale (also assuming you could use a scale too). This leaves 2 balls left that needs to be weighed and 1 out of those 2 balls is the heavier one.ans is minimun 1ans is min 1 first take 2 random balls. weigh them in balance pan. if one is heavier then BINGO u got the heavier ballMinimum 2 attemp Because you have to pick at least 2 balls for comparison of weights..

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

19 Jun 2012
 Given an large list of unsorted numbers, find the smallest number. You can access the list only 3 numbers at a time, and keep moving forward 1 number at a time.6 AnswersOtherwise called the sliding window problemUse the selection sort and after the pass stop the iterating. Time complexity will be O(N) & only one swap.Use the selection sort and after the first pass stop the iterating. Time complexity will be O(N) & only one swap.Show more responsesDid they asked to write the code of the solution? or just pseudo code.And did they added any constraints? Otherwise this is pretty straight forward problem using Insertion sort.You can access the list only 3 numbers at a time: It tells we can read three numbers one after other in N/3 Iterations. So Time complexity will be O(N/3)This is sliding window problem and priority queue DS can be used to solve this.
2130 of 77,156 Interview Questions