# Mobile developer Interview Questions

# 2K

Mobile Developer interview questions shared by candidates### Although I have all the questions from all the interview stages documented in a word file, I am not sure if I am allowed to reveal them here. But to give you a hint, I will paste only a few questions here: Interview 1: how does traceroute work? difference between big endian and little endian (with example)? BSD vs GPL vs LGPL vs FSF vs GNU? 255 & 42 = ? solve in 15 sec 11 << 2 = ? solve in 15 sec what is TTL in a packet? give examples of functional programming languages what other language runs on JVM? Interview 2: write code for fibonacci series. later, improve it. On-site Interview: (can't disclose)

4 Answers↳

Very, very helpful !!!!Can you send it to me ? lastripper@gmail.com

↳

I have applied for the mobile software engineer. do you think they can ask the same question for this post too? Less

↳

Thanks for the review, it was really helpful. Can you send me the word document at johnycamanney@gmail.com Thanks! Less

### Implement a Sudoko puzzle validator - given a 9x9 matrix of numbers (1-9) and "." for empty spaces, return true for a valid puzzle matrix and false if it would not be a valid sudoku puzzle.

3 Answers↳

Each iteration? You need just an iteration. Complexity o(n).

↳

my solution was still O(n) - 3n to be exact. i "iterate" over the entire matrix 3 times - once to check for duplicates in the rows, once to check for duplicates in the columns, and once to check for duplicates within sub matrices. During each of those iterations I visit each element of the matrix exactly once and just check whether it's already in a dictionary of seen numbers which would be a constant time operation, so this is in total would be O(n). I can't think of how to check all those in just one iteration , if that's what you were saying you could do. (at least without using O(n) extra space.. mine only uses constant extra space) i would appreciate if you could elaborate Less

↳

I basically just checked for duplicate numbers in each row, column, and then each 3x3 inner matrix. each iteration, i reset a dictionary of "seen" numbers. "." characters wouldn't matter, if i saw a number 1-9 i would check if it was already in the dictionary, if it was return false. return true at the very end if never encountered repeat numbers in rows, columns, or inner squares. when I explained this approach to the interviewer and he seemed satisfied with it although it was not easy to tell what the hell he was thinking or saying. i was working in a shared text file (i think it was codepen?), and even though the interviewer could have typed too, he didn't (even when i had to ask him repeatedly to spell a word i couldn't make out).. Less

### Algorithms question was probably the trickiest thing. Given an array of integers of length N from 1 to N-1, how would you detect a single duplicate in the array?

4 Answers↳

a xor a = 0 0 xor a = a so if we xor all elements 1 x 1 x 2 with all possible elements 1x2x3 = 0x3 = 3 still extra memory used but at least no overflow possibility. was it allowed to change the original input ? Less

↳

1) Subtract each number from summation formula = N * (N+1) / 2 2) Hash table , zero out all entries when insert number -> 1 after all insert look for 0 entry 3) XOR all elems -> X XOR all # 1 to N -> Y XOR of X and Y -> missing # 15 ^ 12 ^ 15 = 12 Less

↳

Stupid Math this is called stalking not algorithm

### What's the angle between the hands of a clock if the time is 3:15.

3 Answers↳

Oooooh, this was a sneaky trick question and I'm sorry I fell for it. Under the pressure of an interview, you might accidentally think the angle between the small and the large hands of a clock will pointing at the number "3" and therefore the angle would be zero. If you can keep a clear head, you're likely to realize really quickly that the small (hour) hand is going to be *beyond* the 3 by some relatively small angle. To be more precise, it'll be 1/4th of the distance between the hour numbers "3" and "4". Less

↳

With 360 degrees in a circle and 12 hours throughout each cycle the distance between each number is 30 degrees. If the minute hand is pointing at the 3 and is fifteen minutes, fifteen minutes is 1/4 of the total amount of minutes on the clock, this puts the hour hand 30/4 degrees passed the 3 at 7.25 degrees. They'll enjoy you thinking analytically. Less

↳

The answer should be a right angle.

### Implement Integer.parseInt from scratch

3 Answers↳

to study for this interview I suggest rewriting all of the basic Java methods ;)

↳

can't u just parse char by char and use a bunch of shift operators and since ur just using charAt(i) to pick up a character u can use the same i and just raise it to the power of 10 and just or it with some bytes Less

↳

public static int parseInt(String stringToConvert) { int i =0,num=0; int isNeg = 1; int length = stringToConvert.length(); if(stringToConvert.charAt(0) =='-') { isNeg=-1; i=1; } while(i Less

### Hardest Q was: Here's a binary tree: find the longest path within it. So, find a path between any two leaf nodes, where the path is the longest.

3 Answers↳

class Solution{ int ans[] = new int[1]; //O(n) public int efficientDia(TreeNode root) { if(root == null) return 0; int left = efficientDia(root.left); int right = efficientDia(root.right); ans[0] = Math.max(ans[0], 1 + left+ right); return 1+ Math.max(left, right); } //O(n^2) public int getDiameter(TreeNode root) { if(root == null) return 0; int leftHeight = getHeight(root.left); int rightHeight = getHeight(root.right); if(ans[0] < 1 + leftHeight + rightHeight) { ans[0] = 1 + leftHeight + rightHeight; } return Math.max(getDiameter(root.left), getDiameter(root.right)); } Less

↳

int ans[] = new int[1]; //O(n) public int efficientDia(TreeNode root) { if(root == null) return 0; int left = efficientDia(root.left); int right = efficientDia(root.right); ans[0] = Math.max(ans[0], 1 + left+ right); return 1+ Math.max(left, right); } //O(n^2) public int getDiameter(TreeNode root) { if(root == null) return 0; int leftHeight = getHeight(root.left); int rightHeight = getHeight(root.right); if(ans[0] < 1 + leftHeight + rightHeight) { ans[0] = 1 + leftHeight + rightHeight; } return Math.max(getDiameter(root.left), getDiameter(root.right)); } private int getHeight(TreeNode root) { // TODO Auto-generated method stub if(root == null) return 0; return Math.max(getHeight(root.left), getHeight(root.right))+1; } Less

↳

Indians at all companies always ask tree questions, it makes them giggle inside. I know, because I'm half indian and have interviewed people... tee hee hee Less

### If you have less memory storage, what would you use - Hash Table or Tree? Why?

3 Answers↳

I think the point is, hash tables are generally fairly empty, to increase search times so they take up a lot of memory space, but with a binary search tree, the information is very dense, so it would take up less space. Less

↳

Yes they ask you which takes up less memory and there are multiple answers due to the number of elements (as you've stated) as well as the type of the data being stored. A hash table would be better if there aren't many elements since you typically have more slots than you have actual elements so you aren't resizing on every insert. Similarly if you're storing larger object say of 64 bytes, then the extra pointer data stored in a basic tree doesn't amount to much in comparison. However if you're storing something like a character or even a 32-bit integer, a binary tree will take more space since each node (in a basic implementation) needs to store (assuming 32-bit pointer) 64-bits with of pointers per element. Point is the question is stupid without further information since the answer depends on information they don't give you. But they do expect you to use a binary tree. Less

↳

If minimizing memory footprint is the only requirement, I would use nothing, since nothing doesn't take up any memory and satisfies the functional requirement. Are you asking me which of these takes up less memory? That depends on the number of elements in the storage. But usually, a hash-table has less memory overhead Trees have overhead associated with every node. Less

### You have a set of stairs. You can only move one or two steps at a time. Calculate how many possible combinations of moves can be made to traverse the exact number of steps, for any given total number of steps.

3 Answers↳

^ yes it can, but that is a memorized solution that you likely wouldn't implement if you hadn't seen it before. i'm sure they don't use recursion on clients and i'm not exactly sure what this problem says about the interviewer other than "he doesn't leet". Less

↳

It's actually a pretty simple dynamic programming problem you can solve using constant space, do it iteratively rather than recursively. Check it out of LeetCode. Less

↳

This can be calculated with a simple recursive Fibonacci

### Write a program/function to print out numbers from 1 to 100. If a number is multiple of 3, print "Foo" instead. If a number is multiple of 5, print "Bizz". If a number is multiple of both 3 and 5, print "FooBizz".

2 Answers↳

public void printNumbers () { for (int i = 1; i <= 100; ++i) { if (i % 3 == 0 && i % 5 == 0) { System.out.println("FooBizz"); } else if (i % 3 == 0) { System.out.println("Foo"); } else if (i % 5 == 0) { System.out.println("Bizz"); } else { System.out.println(i); } } } Less

↳

public void printNumbers () { for (int i = 1; i <= 100; ++i) { if (i % 15==0) { System.out.println("FooBizz"); } else if (i % 3 == 0) { System.out.println("Foo"); } else if (i % 5 == 0) { System.out.println("Bizz"); } else { System.out.println(i); } } } Less

### dispatch queues … what are they and how do they work?

2 Answers↳

dispatch queues manage the tasks you provide to GCD and execute those tasks in FIFO order. Types of dispatch queues include serial, concurrent and the main dispatch queue (where the UI happens). Less

↳

In these sorts of interviews you really need to drill down and understand what the interviewer is looking for. A good way to simulate a real interview experience is to do a mock with one of the Envoy Mobile Software Engineer experts on Prepfully, rated super strongly on TrustPilot... prepfully.com/practice-interviews Less