Engineer Interview Questions
engineer interview questions shared by candidates
Top Interview Questions
Software Engineer at Google was asked...
Suppose that you earn 100% annual interest (APY) on $1 initial deposit. How long before you'll be as rich as Bill Gates ($63 billion)? Given a number, e.g., 314159, as an array [3,1,4,1,5,9], increment it: change it to [3,1,4,1,6,0]. 17 AnswersTaking just the information we are given and ignoring taxes etc. 100% annual (compound) interest is the same as doubling your investment every year. So for the first four years it would go like this: $1, $2, $4, $8, $16, $32, ... Look familiar? Therefore: 63 Billion = 2^x or x = log2(63 billion) In an interview we wouldn't be able to throw this into a calculator so we would need to do it by hand. We can estimate powers of 2 as powers of 1000: 2^10 ~= 1000^1 2^20 ~= 1000^2 etc. Therefore 63 billion = 63 * 1000^3 or approximately = 63 * 2^30 We know that 64 is 2^6 so we can substitute that with the 63 to get: 2^6 * 2^30 which = 2^36 log2 of 2^36 is 36 Therefore you would have $63 billion after 36 years. Now if we validate with the calculator we see that after 36 years we would actually have about $68/$69 billion. While if we only waited until 35 years we would only have $34 billion. @Sam That's not actually correct as you have not considered the first year where money increases from $1 to $2, so the correct answer is 37 years... It toke ^ 10 to for 2 to reach 1k. So it will take ^ 30 to reach 1b. Then u need another ^ 6 to just pass 63b. S the answer is 36 years. Show more responses Sorry for TYPO (if there are) Each element in the array is a digit in which its value is an integer between 0 to 9. We start with the Least Significant Bit (LSB) at the array and add increase it by 1. For example if the number is 123 than the array will look like: [1, 2, 3] What we do is 3 + 1 = 4 If the result of the operation is smaller than 9 than we write the result at the cell which represent this digit at the array. In the above example the result of the increase will be: [1, 2, 4] When the result is bigger than 9 than we we write 0 at the cell which represent this digit at the array and remember to add 1 at the next stage (the next stage we add 1 to the next Significant bit). For example to increase 129 [1, 2, 9] we perform 9 + 1. the result is 10 than we write 0 in the LSB (where the digit 9 used to be) [1, 2, 0] Next we continue to increase the next Significant bit , in that example we increase 2. i.e and again ask if the result is bigger than 9. 1 + 2 So, in our example, after the next step, it will look like : [1, 3, 0] we continue to do so up until the result of the digit is less than 10. Please pay attention to the following case (overlap) [9, 9, 9] I will leave you all my dear to treat it ;) Possible Java Array Incrememnt Function // Possible Java Array Incrememnt Function public static void inc(ArrayList input) { for (int i = input.size() - 1; i >= 0; i--) { if (input.get(i) == 9) { if (i == 0) { input.set(i, 1); input.add(0); } else { input.set(i, 0); } } else { input.set(i, input.get(i) +1); break; } } } #!/usr/bin/python -tt arr = [3,1,4,1,5,9] def incArr(a, p=-1): """To increase the argument number represented by an array of digit from MSD to LSD by one.""" if (p < 0): p = len(a) if (p == 0): a[0:0] = [1] elif (a[p-1] == 9): a[p-1] = 0 incArr(a, p-1) else: a[p-1] = a[p-1] + 1 incArr(arr) print arr #!/usr/bin/env perl my @a = (3,1,4,1,5,9); my $n = join "", @a; print ++$n; Update (I missed the part where you need to give back an array) : #!/usr/bin/env perl my @a = (3,1,4,1,5,9); my $n = join "", @a; $n++; my @b = split //, $n; #@b contains your answer Golf: perl -MData::Dumper -e'@a=(3,1,4,1,5,9);$b=join "",@a;print Dumper([split //,++$b]);' The first answer should be 6 years An int is ~4billion , 32 bits , can solve it from there as 37. def shift(arr): arr = reduce(lambda x,y: x+y,arr) def incr_arr(arr,arrlen): arr_len = arrlen #print arr #print arr_len # base case arr_len = 0 if arr_len == 0: arr[0:0] = [1] # base case arr_len = 1 elif arr_len == 0 and arr[0] ==9: arr[0,1] = [1,0] # all other cases elif arr[arr_len-1]==9: arr[arr_len-1] = 0 incr_arr(arr,arr_len-1) else: arr[arr_len-1] = arr[arr_len-1]+1 # test cases arr = [9,9]; print arr,"---",; arr_len = len(arr); incr_arr(arr, arr_len); print arr arr = [9];print arr,"---",; arr_len = len(arr); incr_arr(arr, arr_len); print arr arr = [0,1]; print arr,"---",;arr_len = len(arr); incr_arr(arr, arr_len); print arr arr = [1,9]; print arr,"---",;arr_len = len(arr); incr_arr(arr, arr_len); print arr Show more responses def incr_arr(arr,arrlen): arr_len = arrlen #print arr #print arr_len # base case arr_len = 0 if arr_len == 0: arr[0:0] = [1] # base case arr_len = 1 elif arr_len == 0 and arr[0] ==9: arr[0,1] = [1,0] # all other cases elif arr[arr_len-1]==9: arr[arr_len-1] = 0 incr_arr(arr,arr_len-1) else: arr[arr_len-1] = arr[arr_len-1]+1 # test cases arr = [9,9]; print arr,"---",; arr_len = len(arr); incr_arr(arr, arr_len); print arr arr = [9];print arr,"---",; arr_len = len(arr); incr_arr(arr, arr_len); print arr arr = [0,1]; print arr,"---",;arr_len = len(arr); incr_arr(arr, arr_len); print arr arr = [1,9]; print arr,"---",;arr_len = len(arr); incr_arr(arr, arr_len); print arr Was good yes definitely it should be in 36year right int main() { cout > Balance; return 0; Year=1balance: 2 Year=2balance: 4 Year=3balance: 8 Year=4balance: 16 Year=5balance: 32 Year=6balance: 64 Year=7balance: 128 Year=8balance: 256 Year=9balance: 512 Year=10balance: 1024 Year=11balance: 2048 Year=12balance: 4096 Year=13balance: 8192 Year=14balance: 16384 Year=15balance: 32768 Year=16balance: 65536 Year=17balance: 131072 Year=18balance: 262144 Year=19balance: 524288 Year=20balance: 1.04858e+06 Year=21balance: 2.09715e+06 Year=22balance: 4.1943e+06 Year=23balance: 8.38861e+06 Year=24balance: 1.67772e+07 Year=25balance: 3.35544e+07 Year=26balance: 6.71089e+07 Year=27balance: 1.34218e+08 Year=28balance: 2.68435e+08 Year=29balance: 5.36871e+08 Year=30balance: 1.07374e+09 Year=31balance: 2.14748e+09 Year=32balance: 4.29497e+09 Year=33balance: 8.58993e+09 Year=34balance: 1.71799e+10 Year=35balance: 3.43597e+10 Year=36balance: 6.87195e+10 |
Software Engineer at Google was asked...
Quickly estimate 2^64 without using a pen/papar. 11 AnswersWell, 2^8 is 256 and 2^16 is that squared, which should have 5 digits.. If I square it again, I should have double those digits, and again if I square it again.. So I'm looking for something in the neighborhood of 1x10^20, or approx 10,000,000,000,000,000,000. Calculator says: 18,446,744,073,709,551,616--> I'm in the ballpark. 2^10=1024 ~10^3 2^64=(2^10)^6 * 2^4 => (10^3)^6*16 => 10^18*16 => 1.6 * 10 ^ 19 = 16,000,000,000,000,000,000 Calculator says: 18,446,744,073,709,551,616 2 ^ 10 = 1.024 * (10^3) 2 ^ 60 = (1.024 ^ 6) * (10 ^ 18) 2 ^ 64 = (16 * (1.024 ^ 6) * (10 ^ 18) ) All, we need to solve is 1.024 ^ 6. using binomial expansion, ignoring the smaller terms we get : (1 + 0.024) ^ 6 = 1 + 6 * 0.024 = 1.144 = 1.15 (approx) Hence the answer is : (16 * 1.15) * (10 ^ 18) = 18.4 * (10 ^ 18) It is much closer to the actual answer and very fast to calculate. Show more responses Donno if this is to test witt and prepness.. I would say 18,446,.... so on He ll ask how i get that.. Say "calculator" The question was about without using pen/paper 2^32 ~= 4 bil 2^64 = 4bil * 4 bil = 16 bil bil each bil 9 0's, so 16 with 18 0's. It is 16 billion billions They are talking about 64 bit integer, where left most bit is set to 1, and rest to 0. Considering it is 64 bit unsigned integer, it should be equal to value of 32 unsigned integer where all bits are 1, which I guess is somewhere around 4billion, or you can just say 2^64 = UInt32.MaxValue 2^64 the answer is 32 well in binary, 1 followed by 64 0s. They didn't specify answer should be in decimal. One or more comments have been removed. |
Software Engineer at Google was asked...
You have a 64bit interger counter set to 0. How long it will take to overflow the counter given that you are incrementing it at 4Ghz speed. 9 Answers60 years If we were to keep it simple and not consider every increment to be a load, increment, store then we basically need 2^64 increments to make the long overflow. 4GHz means 4*(2^30) instructions per second.. which is 2^32 effectively it is (2^64)/(2^32) = 2^32 seconds.. or roughly 136years. total increments before overflow (tibo) = 2^64 increment speed(is) = 1 second / (4*10^9) increments | 4Ghz = 1x10^9 Hz total seconds (ts) = 2^64 increments * (1 second /(4*10^9) increments) ts = 4.611 * 10^9 seconds total years = ts/(60*60*24*52) = 146.2 years Show more responses total years = ts/(60*60*24*7*52) = 146.2 years and 4ghz = 4*10^9 Hz Please read the question carefully, it says counter is incrementing at the rate of 4GHz. i.e, 4GB per second. Not incrementing every second. So after elapsing first second, counter is at 4GB. After elapsing 2nd second, it is 4 + 4 = 8GB. 64 bit integer is, 2^64 = 2^32 * 2^32. Which is roughly 4GB * 4GB = 16GB. So per second counter incremented to 4GB, so for 16GB it takes 4 seconds. Anonymous: 4GB * 4GB != 16 GB. You're ignoring the units! To be accurate, the answer is 4G * 4G = 16 G^2 = 16 * 2^30 * 2^30. guys note: the counter is initialized to 0. and overflows when you increment the counter when it holds 2^32. its take 2 second right python: (float(2**64)/(4*10**9))/(24*60*60*365) 146.235604338768 years. |
Cloud Support Engineer at Amazon was asked...
Asked me about Networking, Windows Servers, SQL query and Linux. Basic commands and scenario based question. 7 AnswersCan I ask when you had your written exam? why you asking that? did you also give interview? have you got selected Well I had my written exam around 2 weeks ago, and still haven't heard from them yet. So just wondering how long you got contacted after the written exam? Show more responses I gave pre-employment written exam on one Friday and got the call for second stage interview by coming Wednesday. On Friday we had the written exam and Sunday was due date for assignment. All the best. Sometimes they might take longer to reply. Keep us updated. hi! can you please tell me what kind of questions did they ask you in the pre empl. written exam ? It was 5 page exam. Networking, Windows Server, Linux commands, Scripting and Internet protocols. All the best. Written exam? They do have now written exam as a part of interview? |
This job is not 9 to 5 and very stressful and you sure you can do this? 6 AnswersYes! (desperate need a job for as a graduate) I took a job here as well because i needed one as a graduate. I kept looking and found a much better job a few weeks later. Anyone care to elaborate more on the interview process? Cheers Show more responses Anyone know what kind of questions they ask in the interview? Thanks they will take you as long as you say you able to work from 5 to 9 Lol look at funny graduates who desperately want a random job and say I can do whatever company asks, and then quit in 3 months complaining about the toxic company culture. Grow up! |
Explain what happens when you open a web browser and type in "google.com" 6 AnswersWhy did you decline? To be honest, I declined it because I had a better offer. Better in the sense of more money, and lots of travel opportunities. I would love to work for Amazon, but if someone wants to pay for me to spend 4 months in Asia, I'm not going to say no. I still highly recommend applying for this job, and if I didn't accept this other one, I would have definitely accepted Amazon. I see, thanks for the reply, and congrats on the job! How long did it take Amazon to contact you after submitting the take-home assignment? I submitted mine late last week (Thursday) and am still waiting... Show more responses Hi, me again, the Anon from above. Writing to you again on the off-chance that you happen to check this before Friday as I've been invited for an on-site interview. I'd appreciate any more details you're willing to share in regards to the on-site process: when you say it "covered your personality" does this refer to behavioral and/or aptitude type questions? Were the technical questions they asked similar to the sort of questions on the test? I'd love any examples of questions they asked you or advice you'd have for me. Also FYI: Anyone else reading this that might be wondering - it took Amazon just under two weeks after I submitted the take-home assignment to invite me for an on-site interview. Hey, Sorry i read the email saying you replied the other week but forgot to actually type a response lol. The personality was just questions about previous roles/Uni where you were faced with challenges and how you handled them. The technical questions were relating to your strong points from the test (which was a real nice change lol). I also got asked to explain my answer from the take home assignment. I personally found the interview quite easily, because as I said, it was to do with your strong points. The guys are all really nice, and I had a good laugh with them. If you don't know the answer to something, be sure to ask them to explain it to you as they want to know you that you are keen to learn. Good luck! Thanks for getting back to me man. That's awesome advice I really appreciate it!! |
How to implement a queue simply using two stacks and how to implement a highly efficient queue using two stacks. 7 AnswersDeclare two stacks called in and out. queue.insert() calls in.push() queue.remove() if (out.notEmpty) out.pop() else { while(in.notEmpty) out.push(in.pop) } Don't get how this would be two questions. Because that is the simple implementation, pretty much the exact same answer I gave them, there apparently is a more efficient way of modelling it. Queue should implement FIFO. Let's have a group of task 1 -10 to be performed //declare two stacks Stack S1, S2; //feed stack S1 with the tasks 1 - 10 for(int i=1; i<=10;i++) { S1.push(i); } //Now S1 contains {10,9,8,7,6,5,4,3,2,1} where the top is 10 //Transfer all from S1 to S2 while(!S1.isEmpty()) { S2.push(S1.pop()); } //Now S2 contains {1,2,3,4,5,6,7,8,9,10} where the top is 1 You can now pop tasks from S2. Task 1 will be the first to pop and so on... Therefore, you just simulated FIFO using two stacks Show more responses blakdogg's answer is efficient, and has amortized time O(n). The trick here is that when you enqueue an element, you only push into one stack. Only move element when dequeue. Otherwise, running time will be more than O(n). Details are in CLRS amortized analysis. template class Q{ private Stack S1,S2; public Q(); ~Q(); void enQ(item *); item* dQ(); int empty(); } void Q::enQ(item * i){ if(S1.empty&&~S2.empty) while(~S2.empty) S1.push(S2.pop()); S1.push(i); return; } item Q::dQ(){ if(S2.empty&&~S1.empty) while(~S1.empty) S2.push(S1.pop()); return S2.empty?0:S2.pop; } int Q::empty(){ return S1.empty()&&S2.empty; } Q::Q(){ S1=new Stack; S2=new Stack; } Q::~Q(){ delete S1; delete S2; } Please check my videos that explain "How to implement a queue from two stacks?" Part 1 - https://www.youtube.com/watch?v=_PIRZqC0pS0 Part 2 - https://www.youtube.com/watch?v=D2Z2iGQW7cM Part 3 - https://www.youtube.com/watch?v=DeChmB6JSZw One or more comments have been removed. |
Software Engineer at Google was asked...
Find the longest subsequence of duplicate numbers in an array of sorted numbers. 5 AnswersA binary search with two partitions (i.e. partition list into thirds) will get you a logarithmic time solution. I got this solution, but I think I took too long to do it compared to the other candidates. Hi there, can you elaborate on what you mean by using a binary search? I've been thinking about what you said for the last 10 minutes and I can't understand would a binary search help here. Just curious, thanks If the array is sorted, you can simply go through elements one by one and count the duplicate numbers. The complexity is linear. Could it be so trivial? Show more responses Linear is o(n), binary search takes just o(logn) Jumping in powers of 2 would be O(log n) for best case scenario rather than linear search's O(n). Worst case scenario they would both be O(n). Logic: - Let n be the position you are currently checking for the longest subsequence (starts at 0) - K = 0 - While arr[n] == arr[n + 2^K] do - K++ - If 2^K is > the previously known longest subsequence - Binary search between 2^K-1 and 2^K to find the exact length of the current sequence - Store it as the longest known subsequence - Repeat with n as the position you are at now + 1 |
Android Developer at Facebook was asked...
Typical Android Layouts (What's the best way to lay element vertically etc.). Android Lifecycle. LinkedList vs Arrays. 4 AnswersI guess the answer to the first question would be listView? Or if is supposed to be a layout, LinearLayout would be my solution. Yes, the answer is (obviously) a Vertical LinearLayout. I had a bit of a brain fart and called it a Linear ListView, which is incorrect. Hello Michael, Have you been in a FB's interview before? Show more responses Hi, Yes, I'm the original poster - I got the phone screen but did not go to the next round unfortunately. |
Why are manhole covers round 3 AnswersThere is no right or wrong answer here. The hiring manager is trying to understand the thought process you go through to answer a question. They're round because, given that they have bevelled edges, that shape makes it impossible to drop the cover down the hole. They are round because the shaft that you descend into, after removing the manhole cover, is round. |
See Interview Questions for Similar Jobs
- Senior Software Engineer
- Software Developer
- Java Developer
- Senior Software Developer
- Developer
- Engineer
- Senior Java Developer
- Analyst
- Project Manager
- Business Analyst
- Product Manager
- Senior Developer