Fragen im Bewerbungsgespräch: Software engineer in Region Bengaluru, Indien | Glassdoor.de

# Fragen im Vorstellungsgespräch: Software engineer in Bengaluru, Indien

23,605

Fragen aus Vorstellungsgesprächen für software engineer, von Bewerbern geteilt

## Top Vorstellungsgespräch-Fragen

Sortieren: RelevanzBeliebtheit Datum

23. Apr. 2010

24. Dez. 2015

### Ein Bewerber für eine Stelle als Software Engineer bei Google wurde gefragt...

19. März 2009
 Come out with an algorithm for getting the column number provided the column name in a excel sheet and vice versa. Excel has a naming convention of A,B..Z,AA,AB,AC..ZZ,AAA... This had to be converted to the column numbers. A will be 1 and AA will 27.. Also the algorithm to find the name provided column number.13 AntwortenIts conversion from decimal to base 26 with some exception like there is nothing maps to zero. There might be a better way to do it.void printColumn(uint32_t col) { col --; int div = 26; int add = 26; while( col / div ) { div *= 26; } div /= 26; while( div != 1) { printf("%c", (col / div) + 'a' - 1); col = col % div; div /= 26; } printf("%c\n", col + 'a'); }Opps above does not work after ZZ. The correct one is void printColumn(uint32_t col) { int a = 26; int denominator = 1; while(a 0; i /= 26) low += i; // if value is lower than lower bound, decrease quotient by one if( denominator != 1 && col < (quotient * denominator + low) ) { quotient --; } printf("%c", quotient - 1 + 'A'); col = col - denominator * quotient; denominator /= 26; } }Mehr Antworten anzeigenLet the size of the string asked is 3 e.g GHD . The formula to this : [ 26+26^2+...+ 26^(size-1) + (LetterIndex-1)*{26^(size-1)+....+(LetterIndex-1)*26}+Index ]In the code the above formula will use recursion to find the column number.The answer can be as simple as finding the first combination of number * i such that it is less then xcelcolvalue; ie repeat this till xcelColValue >= 26 ( 0 = 26){ int i = 1, num = 1; while((num * (i + 1)) 26){ i = 1; num++;} else i++; xcelNum -= num*i; sb.append((char) i); } if (xcelNum > 0) sb.append((char) xcelNum); return sb.toString(); }Also the above code is rough idea and not tested but gives enough idea on simplifying the solution. The code does not use lot of / and % calcuations but could elegantly find the solution. Note the Gaurd if(i > 26){ i = 1; num++;} else i++; which is important in finding the combination of num and i which multiples at least to xcelNum.I think the above is incorrect and it should be : public static String xcelString(int xcelNum) { StringBuffer sb = new StringBuffer(); while(xcelNum >= 26){ int i = 1; for(;(26 * (i + 1)) 0) sb.append((char) xcelNum); return sb.toString(); }Edge conditions aside, the program would be /* inputString - the column name. For e.g. "BZC" */ char [] columnName = inputString.toUpperCase().toCharArray(); int columnNumber = 0; for(int i = 0; i < columnName.length - 1; i++){ columnNumber = columnNumber + (int) Math.pow(26, (columnName.length - 1 - i)) * (columnName[i] - 64) ; } columnNumber = columnNumber + (columnName[columnName.length - 1] - 64); System.out.println("Column number is " + columnNumber);Edge conditions aside, the program would be /* inputString - the column name. For e.g. "BZC" */ char [] columnName = inputString.toUpperCase().toCharArray(); int columnNumber = 0; for(int i = 0; i < columnName.length - 1; i++){ columnNumber = columnNumber + (int) Math.pow(26, (columnName.length - 1 - i)) * (columnName[i] - 64) ; } columnNumber = columnNumber + (columnName[columnName.length - 1] - 64); System.out.println("Column number is " + columnNumber);int columnNumber(String col) { result = 0; for(i = 0;i< strlen(col) ; i++) { result *= 26; result + = col[i] - 'A' +1; } }int columnNumber(String col) { result = 0; for(i = 0;i< strlen(col) ; i++) { result *= 26; result + = col[i] - 'A' +1; } }public static String numToExcel(int n) { if(n 0) { int remainder = n%26; char newChar = (char) ('Z' - (26 -remainder)%26); result = newChar + result; n = (n-1)/26; } return result; }

### Ein Bewerber für eine Stelle als Software Developer bei Knab wurde gefragt...

27. Aug. 2016
 Scan an integer and print the alphabet so that: 1-A; 2-B...26-Z; 27-AA,28-AB,29-AC...52-AZ; 53-AAA,54-AAB,55-AAC...78-AAZ...etc.. If you provide an integer, say 28-it should print AB. If you scan another integer say 55, it should show AAC13 AntwortenI was not able to complete within 20 minutes, hence got rejected.#include #include int main() { int n=0,ap=0; printf("Enter no - "); scanf("%d",&n); ap=n%26; while(n>26) { printf("A"); n-=26;; } switch(ap) { case 1 : printf("A"); break; case 2 : printf("B"); break; case 3 : printf("C"); break; case 4 : printf("D"); break; case 5 : printf("E"); break; case 6 : printf("F"); break; case 7 : printf("G"); break; case 8 : printf("H"); break; case 9 : printf("I"); break; case 10 : printf("J"); break; case 11 : printf("K"); break; case 12 : printf("L"); break; case 13 : printf("M"); break; case 14 : printf("N"); break; case 15 : printf("O"); break; case 16 : printf("P"); break; case 17 : printf("Q"); break; case 18 : printf("R"); break; case 19 : printf("S"); break; case 20 : printf("T"); break; case 21 : printf("U"); break; case 22 : printf("V"); break; case 23 : printf("W"); break; case 24 : printf("X"); break; case 25 : printf("Y"); break; case 0 : printf("Z"); break; default : break; } }#include #define N 26 int main(){ int i,no,no1; printf("\n Enter number : "); scanf("%d",&no); if(no 26){ printf("A"); no1 -= 26; } if(no == 0) no = 26; // code for finding the particular alphabet from A-Z for(i = no; i <=no; i++){ printf("%c",'@'+i); } } return 0; }Mehr Antworten anzeigen#include int main(){ int i,no,no1; printf("\n Enter number : "); scanf("%d",&no); if(no 26){ printf("A"); no1 -= 26; } if(no == 0) no = 26; // code for finding the particular alphabet from A-Z for(i = no; i <=no; i++){ printf("%c",'@'+i); } } return 0; }import java.util.Scanner; public class Alpha { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(),temp=0, count = 0,rem=0; String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if(n26){ count = n/26; rem = n%26; if(rem != 0){ for (int i = 0; i < count; i++) { System.out.print("A"); } temp = n - count*26; System.out.print(alpha.charAt(temp-1)); } else{ for (int i = 0; i < count-1; i++) { System.out.print("A"); } System.out.println("Z"); } } } }#include int main() { int num; printf("enter a number\n"); scanf("%d",&num); while(num>26) { printf("A"); num=num-26; } if(num<=26) { printf("%c",num+64); } return 0; }#include int main() { int n; printf("Enter a Number ::: "); scanf("%d",&n); int tmp =n/26; int val=0; while (tmp>0) { tmp--; if (tmp==0 && n%26==0) { printf("Z"); val++; break; } if (!(tmp<0)) { printf("%c",65); } } if (val!=1) { printf("%c", (n%26)+64); } printf("\n"); }By mistake I pressed down vote. Nice code - > PoornimaBimport java.util.*; public class Program3 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if(n26)&&(n52)&&(n<78||n<=78)) { int a=n%26; a--; int b=65+a; char ch=(char)b; if(n==78) ch='Z'; System.out.println("AA"+ch); } } }import java.util.*; public class Program3 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if(n26)&&(n52)&&(n<78||n<=78)) { int a=n%26; a--; int b=65+a; char ch=(char)b; if(n==78) ch='Z'; System.out.println("AA"+ch); } } }LANGUAGE OF MY CODE IS JAVA BUT IT WILL HELP YOU TO GET LOGIC public class part2 { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("enter a number"); int n=scan.nextInt(); int fact; fact=n/26; if(n%26==0){ fact=fact-1; } for(int i=0;iLEFT PORTION OF ABOVE CODE IS HERE for(int i=0;istatic string Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public static void numToString(int num) { if(num<=26) { Console.Write(Alpha[num - 1]); return; } Console.Write('A'); numToString2(num - 26); }

### Ein Bewerber für eine Stelle als Junior Software Engineer bei Pratian Technologies wurde gefragt...

15. Juni 2015
 write a program to print the given series (user need to enter the nth series number from keyboard) 2,3,5,11,23,29,41,53,83,89 .....n11 Antwortenimport java.util.Scanner; public class prg2 { public static void main(String[] args) { //2,3,5,11,23,29,41,53,83,89 .....n int i,count=0,n,j,flag,x=0; System.out.println("Enter number of term:"); Scanner sc=new Scanner(System.in); n=sc.nextInt(); for(i=2;true;i++){ flag=1; for(j=2;j<=i/2;j++){ if(i%j==0){ flag=0; break; } } if(flag==1){ ++count; if(count%4!=0){ System.out.println(i); ++x; } } if(x==n) break; } } }import java.util.Scanner; public class Series2 { static Boolean prime(int p) { for(int i=2; iwhat's the logic?Mehr Antworten anzeigen#include main() { int i,k,n,m,count=0; scanf("%d",&n); for(i=2;i<=n;i++) { for(k=0;k<=i;k++) { if((i%k==0)) count++; } if(count==2) m=2*i+1; count==0; for(k=0;(m!=0)&&(k<=m);k++) { if((m%k==0)) count++; } if(count==0) printf("%d",m); } }#include main() { int i,n,p,k,count=0,plus=0; printf(:enter the no\n"); scanf("%d",&n); for(i=2;i#include int prime(int num) { int i,c=0; for(i=2;iAnswer is in java :100% correct public class ProgramDemo { public static void main(String[] args) { System.out.println("Enter the value :"); Scanner read = new Scanner(System.in); int number = read.nextInt(); for(int i=2;i<=number;i++){ if(Prime(i)){ if(Prime(2*i+1)){ System.out.print(" "+i); } } } } static boolean Prime(int a) { int temp, c; for (c = 2; c <= a - 1; c++) { temp = a % c; if (temp == 0) { return false; } } if (c == a) { return true; } return false; } } I Hope its helpful for you :) Plese give me one like for it ....Excellent broimport java.util.Scanner; public class HelloJava { public static void main(String args[]) { int i,flag=0; for( int x = 2 ;x<100 ;x++) { flag=0; for(i=2;i<=x-1;i++) { if(x%i==0) { flag = 1; break; } } if(flag==0) { for( i = 2; iCan anyone please explain the logic?#include #include void main() { int i; printf("Enter no. of terms \n"); for(i=2; i<=50 ; i= 2*i+1) { printf("\n %d", i); } return 0; }

### Ein Bewerber für eine Stelle als Applications Developer bei ThoughtWorks wurde gefragt...

28. Mai 2015
 10 people can share a bucket of coins equally. A monkey steals one coin. The no of coins are one less than equal share. one person after the other tries to take the coin but monkey kills them(killing spree?? :-)). each time a person dies the no of coins are always one short of equal share. what were the no of coins originally?.12 AntwortenI wont give the answer. Hint : know who divides you ;-)if monkey steal one coin then as per your ans coins==9. then one person dies so 9%9 is==0. which is not possible. it is not 20 also just to give a bigger hint.:-)Mehr Antworten anzeigenExact answer is 30 coins. Since each time monkey kills one person.This is correct for 10 coins as wellsuppose initial coins were 30 then money steals one coin so #coins = 29. now 10 people are there and the no of coins are 1 less than equal share i.e if 30 coins were there 3 per person but only 29 coins are there. so this case is ok. lets look for 9 people, since monkey kills one guy. now for 9, 29 is not one short of equal share because 9*3 ==27 , 9*4 == 36 neither of which satisfy the condition. so 30 cannot be the original coins. same thing for 8,7,6,.. 10 coins cannot be the original. Please read the question carefully.. this hint will be the closest to the answer, keep this part of the question in mind : "each time a person dies the no of coins are always one short of equal share".I think it is 2520 i.e.LCM of 2-10I think 2520 is perfectsweet:-) nice ans. also think of 10! since the numbers in factorial are the remaining people after each iteration(2x3x4x5x6x7x8x9x10) and they form factors of the factorial number. and the factorial - 1 will always be one less than equal share. this fits the solution:-)Multiples of 2520 will be the answerYes any Common multiple of the factors is a solution.Answer is pretty simple: m%10=0 -----case 1 Lets assume n=m-1 Since the remainder is always same , when n is divider by any number from 10 to 1.. n%10 = n%9=.........=1 That means n+1 is completely divisible by all numbers from 10 to 1.. (Since it gives common remainder).. n + 1= Lcm of (1 to 10) = 2520 But we assumed n = m-1, so m -1+1 =m = 2520 Einer oder mehrere Kommentare wurden entfernt. Weitere Informationen finden Sie in unserem Verhaltenskodex und in unseren Nutzungsbedingungen.

### Ein Bewerber für eine Stelle als Software Engineer bei Google wurde gefragt...

3. Dez. 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 AntwortenThere 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>2Mehr Antworten anzeigenAder 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 .

### Ein Bewerber für eine Stelle als Software Engineer bei Google wurde gefragt...

17. Juni 2010
 How many rotations does earth make on its axis while going around the sun for one year.12 AntwortenDepends on the Leap Year or non Leap Year 365 for Non Leap Year 366 for Leap YearThe question is flawed. It should either ask how many days earth takes in one revolution around sun, or how many days are in a year. The leap year is something imaginary humans have concocted to make the calendars look good. You can't say once is 4 years earth takes an extra day to go around the sun.It's to get you thinking about casting... the calender is a double casted to an int!Mehr Antworten anzeigen365.25 / yr I wouldn't say 365/ 366 leap year. Jain has a point.^It's either 364.25 or 366.25 depending on whether the earth spins in the same direction as it goes around the sun or not (I don't remember which it is and can't deduce it from the information that's available to me without looking it up). Imagine if the Earth did not spin at all on its axis so it would seem as if a year was equivalent to one day. It will take the Earth rotating either 264.24 or 366.25 times depending on the direction to seem like the 365.25 days that it does take.Every year it takes 365.25 rotations but while making calendar we ignore that 0.25 for 3 years and add an extra day in 4th year.365.25 is WRONG!!! Actually Anonymous is right! Just think about this (lay it out on your desk):
• How many days would there be if the earth would not revolve around its axis?
• How many days would there be if it turned once around it's axis?
• Now do again one, change the direction the earth revolves it's axis, but keep going the same direction around the sun ...
The concrete right answer is 366.25 Here you find details on the exact number (with other proof): :)This question makes no sense.It's other way around, only when earth complete one round, we call it a year. To make human calculations easy, we introduced leap yrs.366 rotations per year with respect to a distinct star.366 rotations in a no leap year with respect to distinct star. Einer oder mehrere Kommentare wurden entfernt. Weitere Informationen finden Sie in unserem Verhaltenskodex und in unseren Nutzungsbedingungen.

3. Nov. 2017