# Applications developer Interview Questions

# 6K

Applications Developer interview questions shared by candidates### 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?.

11 Answers↳

I wont give the answer. Hint : know who divides you ;-)

↳

I think 2520 is perfect

↳

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 Less

### 1. Take an integer input and output the number of 1's in it's binary representation. 2. Implement a mergesort. 3. Explain your level of understanding of data structures (trees, etc.) 4. What makes java different than other languages?

9 Answers↳

Hey, did you hear back from them about the final decision? Also, were u coding in Java or Python? If python, why did they ask you questions on java? Could u share those questions because I have been invited too Less

↳

They ask you what language you feel most comfortable with and ask you questions based on that (I said Java). I haven't heard back but I have been contacted by another recruiter from their Manhattan office so maybe better luck on this second try. Good Luck! Less

↳

Thanks man, best wishes to you too.. Nail it this time

### Tell me a palindrome date before 10-02-2001 (mm-dd-yyyy)

7 Answers↳

i got it to be in the 14 th century ...

↳

Sorry it should be 08-31-1380

↳

how can the month no. will be more than 12 i think the answer should be 29-11-1192 :) correct me if i am wrong..... Less

### Write a Java program to count the number of occurances of each number in a series of numbers.

5 Answers↳

public static void main(String[] args) { int occurrence = 0; Map m = new HashMap(); List nos = new LinkedList(); nos.add(1); nos.add(1); nos.add(2); nos.add(3); nos.add(4); nos.add(3); nos.add(2); nos.add(4); nos.add(5); nos.add(100); Set uniqueNos = new HashSet(nos); for(int temp:uniqueNos) { for(int tempList:nos) { if(temp == tempList) { occurrence++; } } m.put(temp, "Appears "+occurrence +" times"); occurrence = 0; } System.out.println(m); } Less

↳

public class FirstJava { public static void main(String[] args) { int occurrence = 0; List nos = new LinkedList(); nos.add(1); nos.add(1); nos.add(2); nos.add(3); nos.add(4); nos.add(3); nos.add(2); nos.add(4); nos.add(5); nos.add(100); Map uniqueNumberCount = new HashMap(); for(int datano:nos){ int k=1; if(uniqueNumberCount.containsKey(datano)){ k=uniqueNumberCount.get(datano); } uniqueNumberCount.put(datano, k); } for(Map.Entry unique:uniqueNumberCount.entrySet()){ System.out.println(unique.getKey()+" Unique Value --->"+unique.getValue()); } } } Less

↳

import java.util.Scanner; public class Occurrence { public static void main(String[] args) { int n, count = 0, i = 0; Scanner s = new Scanner(System.in); System.out.print("Enter no. of elements you want in array:"); n = s.nextInt(); int a[] = new int[n]; int x[] = new int[n]; System.out.println("Enter all the elements:"); for(i = 0; i < n; i++) { a[i] = s.nextInt(); } System.out.print("Enter the element of which you want to count number of occurrences:"); for(i = 0; i < n; i++) { x[i] = a[i]; } for(i = 0; i < n; i++){ count = 0; for(int j = 0; j < n; j++) { if(a[j] == x[i]) { count++; } } System.out.println("Number of Occurrence of the Element:"+a[i]+"is"+count); } } } Less

### We have a pond containing a single bacterium. The number of bacteria double every 5 minutes, and the pond is full of them in 24 hours. If we started with the same pond but two bacteria, how long will it take to fill the pond?

4 Answers↳

I struggled with this a bit and got close. I believe answer is: 23:55

↳

The first pond started with 1 bacterium and doubled to 2 in five minutes. Therefore, the second pond will take 5 minutes less than the first to be full. ie: 23:55 Less

↳

This is a clear case of Geometric progression. Find the nth term Tn1 = a*r^(n-1). where n = (24 * 60)/5,a = 1 and r=2. when the initial value (a) = 2, the values become n = ?, a = 2 and r = 2. Since Tn1 = Tn2, Equate the RHS of both the equation. Since the base are equal, equate the powers, doing so will give the n value. When n is convert into minutes one get 23 hrs 55 minutes. Less

### What is your weakness?

4 Answers↳

When ever I get a work I never leave that work in between before completing it. This is one of my weakness. Less

↳

i lose my temper quickly

↳

go to their official sites..

### What data structure to use for Smartphone lock screen

4 Answers↳

A 3x3 2D array?, just store the sequence in which the blocks have to be selected

↳

Graph data structure can be used, which consists of vertices, edges and x,y relation between vertices Less

↳

graph (gesture) datastructure

### Given a list 1,0,3,5,0,0,34,5,0,36 push all the zeroes to the end. Develop an in-place algorithm

4 Answers↳

var MoveZerosToRight = function(arr) { let n = arr.length; let i = 0; for(let num of arr) { if(num !== 0){ arr[i] = num; i++; } } while(i < n ) { arr[i] = 0; i++; } return arr; }; Less

↳

Used 2 pointers one for zeroes and other for numbers, occasionally swapping to achieve what I want. Less

↳

How will you be achieving the same order?

### a brain teaser question: you have two balls and one 100-story building. What is minimum tries to figure out which floor will break the ball if a ball is dropped from that floor.

4 Answers↳

Basically a restating of binary search, which is find a value between a min and a max value with the minimum number of searches. Basically start at the 50th floor (in the middle), if the ball breaks, go to the 25th floor and try there; else go to 75th floor and try there. Each round would successively split the remainder in half until you get to the floor which is the solution. If you have unlimited balls, then it'll be about 7 or 8 iterations [(2 to the nth power) minus 1]. The problem is more complex because of the limit of the number of balls. This means that some sort of linear search may also be required--if the exact floor must be found. Drop one from the 50th floor, if it breaks, start at the first floor and go up. At that point, on average it'll take to the 25th floor to get an answer, but may take all 49 floors. If the first ball doesn't break on the 50th floor, try it again from the 75th floor. Whether or not it breaks determines whether the binary search continues or the linear search starts. The maximum tries gets smaller depending on when the search transitions from binary to linear, if it ever does. In this case the minimum is the situation where the search never transitions from binary to linear--in other words, a binary search is used the whole time--thus the minimum is the same as for a binary search. Where the ball breaks is somewhere between the 98th and 99th floor. So the real point to take away from this is that they asked for the MINIMUM, not the maximum or average. Binary search always yields a minimum search for an ordered list (or 100 story building) so you can go straight to that answer. Less

↳

Actually the minimum would never be 1 (well not never, it would be 1 if the ball breaks at lvl1) if you want to prove the lowest exact level that will break the ball you need to use at least one other try to prove that the immediately lower level won't break the ball. o even if you use physics to calculate the floor you still need another try to prove your theory. But this is a programming interview so you have to use a mix of binary and linear search, you have to use the mix because of the 2 balls limit as specified above :). Less

↳

The answer is 1. go to the 100th floor. drop the ball, if it breaks, the answer is 100. if not, the ball will not break in the building. note the question does not say to figure the lowest floor that would break the ball. it just says "which floor will break the ball ". obviously, the question can have multiple answer, and 100 is definitely one answer...if indeed the building can break the ball. Less

### There are 10 stacks of 10 coins each. 9 of the stacks contain coins that weigh 1g each. The other stack contains coins of 2g each. The coins look the same. We have a scale that we can get a measurement of grams from, not a balance. We can use the scale exactly once to weigh anything here from a single coin to all of them. How can we determine which stack is the 2g coins?

4 Answers↳

Weigh these together: 10 coins from stack 1, 9 from stack 2, etc ending with 1 from stack 10. The weight of these will tell you which stack has the 2g coins. Ex: if it's 1st stack: 65g, 2nd: 64g, 10th: 54g Less

↳

A more eloquent answer would be: Weigh together 1 coin from stack 1, 2 coins from stack2, 3 coins from stack 3, etc. Subtract 55 from that total weight to get the number of the stack with the 2g coins. Less

↳

Excellent question!