Developer Interview Questions | Glassdoor.com.au

# Developer Interview Questions

2,177

developer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

11 Feb 2013
 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 responsesSorry 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] =  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 answerGolf: perl -MData::Dumper -e'@a=(3,1,4,1,5,9);\$b=join "",@a;print Dumper([split //,++\$b]);'The first answer should be 6 yearsAn 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] =  # base case arr_len = 1 elif arr_len == 0 and arr ==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 = ;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 arrShow more responsesdef incr_arr(arr,arrlen): arr_len = arrlen #print arr #print arr_len # base case arr_len = 0 if arr_len == 0: arr[0:0] =  # base case arr_len = 1 elif arr_len == 0 and arr ==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 = ;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 arrWas goodyes definitely it should be in 36year rightint 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

25 Jun 2011
 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,6162 ^ 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 responsesDonno 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/paper2^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 billionsThey 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.MaxValue2^64 the answer is 32well in binary, 1 followed by 64 0s. They didn't specify answer should be in decimal. One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

25 Jun 2011
 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 yearsIf 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 yearsShow more responsestotal years = ts/(60*60*24*7*52) = 146.2 years and 4ghz = 4*10^9 HzPlease 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 rightpython: (float(2**64)/(4*10**9))/(24*60*60*365) 146.235604338768 years.

8 Feb 2010
 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 stacksShow more responsesblakdogg'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. Please see our Community Guidelines or Terms of Service for more information.

21 Oct 2014
 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, thanksIf 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 responsesLinear 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

17 Oct 2013
 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 responsesHi, Yes, I'm the original poster - I got the phone screen but did not go to the next round unfortunately.

25 Jun 2011

### .NET Developer at 4mation Technologies was asked...

2 Oct 2015
 Please note the process may vary for your case- 1. Initial phone interview: non technical. 2. On site group interview: Need to provide presentation in front of groups to share what you can offer the company, why do you choose this company to join, describe one of your previous project experience. You need to complete this presentation within 3 minutes. They will judge how you can communicate with the clients/team-mates by this interview step. 3. Online technical test: You will be provided an online technical test link via email which will contain several technical questions to be completed within a given time. Questions will check your basics in .NET/C#/OOP/SQL/MVC etc. 4. Technical interview: I cannot tell the details of this test as I haven't faced this step.4 AnswersCan you share the name of the test site where you had to give the technical test?The online test was done through interviewzen site. The recruiter will be able to view each of your action during the test time as all your action will be recorded by interviewzen. Recruiter may want to see the approach how you answers the questions rather than the right syntax.Thanks for the feedback. What did they ask you to code? Like a web application or just a problem?Show more responsesI agree with the process for points 1 and 2. The telephone interview and then the group interview are as described.

### Software Developer at carsales.com.au was asked...

14 Feb 2019
 Write pseudo code to print one word for a sequence when it's divisible by 3, another word if it's divisible by 5 and both words if they are divisible by both 3 and 53 AnswersProvided a working pseudo codeSuccessful hires over the past 2 years have been able to complete the coding task in 3 hours.But somehow I wasn't able to start from scratch and finish a presentable, working app with well maintainable code in 3 hours. Maybe I'm too dumb, but I felt at least I deserved a response email after sending the project to the recruiter. I spent more than 3 hours creating the app as per their specs and they didn't utter a word of response. May be just spare a minute to say 'we didn't like the way you handled this... ' or so? Have a heart

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

28 Apr 2015
 The interviewer asked a question about sorting cards. Given a complete set of cards, you should sort them without using extra space. 3 AnswersI solved the interview problem. Computing the index for each card and inserting and swapping them into correct position.Use linked list and solve it with Merge Sort.It's a simple quick sort...
110 of 2,177 Interview Questions

More