Software Senior Interview Questions

75,733 software senior interview questions shared by candidates

You have some sticks with positive integer lengths. You can connect any two sticks of length x and y by paying a cost of x+y. You perform this action until there is one stick remaining. Return the minimum cost of connecting all the given sticks into one stick. Input: 5 2 8 1
avatar

Senior Software Engineer

Interviewed at Google

4.4
Aug 27, 2020

You have some sticks with positive integer lengths. You can connect any two sticks of length x and y by paying a cost of x+y. You perform this action until there is one stick remaining. Return the minimum cost of connecting all the given sticks into one stick. Input: 5 2 8 1

Imagine you are given 10,000 files each containing 1 Million integers. I would you sum all of them and give the final result? ---> Interviewer wanted to test scalability, distributed concepts. He has written the basic code and wanted to improve upon that. Here's the basic code. public getSum(String[] file_names) { int sum = 0; for(String f: file_names) { sum = sum + sumOfFile(f); } return sum; } Questions: What's wrong with above code? Ans: Integer overflow How would you implement sumOfFile? What if 'sumOfFile' takes lot of time to finish computing? How do you fasten the program?
avatar

Senior Software Engineer

Interviewed at Google

4.4
Mar 30, 2017

Imagine you are given 10,000 files each containing 1 Million integers. I would you sum all of them and give the final result? ---> Interviewer wanted to test scalability, distributed concepts. He has written the basic code and wanted to improve upon that. Here's the basic code. public getSum(String[] file_names) { int sum = 0; for(String f: file_names) { sum = sum + sumOfFile(f); } return sum; } Questions: What's wrong with above code? Ans: Integer overflow How would you implement sumOfFile? What if 'sumOfFile' takes lot of time to finish computing? How do you fasten the program?

Viewing 2361 - 2370 interview questions

Glassdoor has 75,733 interview questions and reports from Software senior interviews. Prepare for your interview. Get hired. Love your job.