Software senior software engineer Interview Questions | Glassdoor.co.in

# Software senior software engineer Interview Questions

13,404

software senior software engineer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

### 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); }

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

19 Sep 2010
 if there are 6 people in a team, how many handshakes will be there8 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 times6c2= 15

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

27 Aug 2015
 Swap LSB with MSB of an short integer without temp6 Answers#include int main() { printf("Hello, World!\n"); // your code goes here unsigned char num=0xf7; num = (num > 4); printf("%0x\n", num); return 0; }#include int main() { printf("Hello, World!\n"); // your code goes here unsigned char num=0xf7; num = (num > 4); printf("%0x\n", num); return 0; }#include int main() { // your code goes here unsigned char num=0xf7; num = (num > 4); printf("%0x\n", num); return 0; } Sorry lines got truncatedShow more responses#include int main() { // your code goes here unsigned char num=0xf7; num = (num >4); printf("%0x\n",num); return 0; }uint16_t swapShort(uint16_t x) { return (x>8); }uint16_t swapShort(uint16_t x) { return (x > 8); }

10 Aug 2013

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

20 Nov 2016
 1) If Child class has parameterized constructor and parent class has default constructor . will it work6 AnswersMy answer is yes as java automatically provides a super call on first line of constructor . Interviewer who was almost 35-37 years old so at least have 10-15 years of experience dont know this concept and we argued on this after which i was told to work on my technical skills and I was like common manNope the old man is correct and u were wrong, the answer is it will not workIt will work. As constructor cannot be overriden. It can be just override in same class.Show more responsesThat will work, compiler writes super call in first line of constructor.Yes it will work.It will work, because super() call from child constructor will call no arg constructor of parent which is by default provided by compiler. But if parent also have parameterized constructor then it will not work, because super() call from child constructor will not find no argument constructor in parent

22 Apr 2020

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

10 Feb 2011
 Find 2 or more missing numbers in a set of 100 natural numbers6 AnswersLook at the numbers and pick the highest one. That will be your salary.Sort numbers lowest number = salary print "your salary is" salaryC = U + Rr / Y Where C = natural number U = the universal constant Rr = local variable Y = years of serviceShow more responsesCreate code that sorts the numbers and then write an algoirthm to check to see if the increments between each number is equal to 1. If not, then add 1 to the previous number to get the missing number. Birdie num num.Since its 100 natural numbers the sorting can be done using an array/counting sort in constant time O(100). Now iterate and find the missing elements.Sort the array..create two subarrays with =50 and check count of each array..the one which is sorted..pass it to method which divides it to 1/2 again..

22 Sep 2015