## Android Engineer Interview Questions

- 1of 1 vote
Suppose there is a map with N bikes on it and now we have N individuals,

Design an algorithm so that everyone can get the bike in the shortest distance

- 0of 0 votes
You have a non empty binary array with value 0 and 1. You can flip either 0 or 1 bit of array to make the consecutive element same.You have to return the count of consecutive number with same digit.

Input : [ 1,0,1,0,0,0]

Output : 4

if you flip the value of 1st index to 1, you have 2 consecutive 1 and 2 consecutive 0 so total 4.

input : [0,0,0,0]

output : 3

input : [0]

output 1

there is bug in below code which i couldn't find it.`class Solution { int solution(int[] A) { int n = A.length; int result = 0; for (int i = 0; i < n - 1; i++) { if (A[i] == A[i + 1]) result = result + 1; } int r = 0; for (int i = 0; i < n; i++) { int count = 0; if (i > 0) { if (A[i - 1] != A[i]) count = count + 1; else count = count - 1; } if (i < n - 1) { if (A[i + 1] != A[i]) count = count + 1; else count = count - 1; } r = Math.max(r, count); } return result + r; } }`

- 1of 1 vote
Given a Map (representing an old phone key number and possible letters present there) and a sequence of keys return all possible combinations of strings that are possible to produce.

`Map<String, String[]> map = new HashMap<String, String[]>(); map.put("1", new String[] { "a", "b", "c" }); map.put("2", new String[] { "c", "d", "e" }); map.put("3", new String[] { "f", "g", "h" }); String in = "12"; List<String> mix(String in, Map<String, String[]> map)`

The result for "1,2" should be [ac, bc, cc, ad, bd, cd, ae, be, ce]

- 0of 0 votes
Given a linked list with next and random pointer, deepcopy the linked list and return new head.

Node {

char val,

Node next,

Node random }

A {

val: ’a’

next: D

random: G}

D {

val: ’d’

next: G

random: A}

G {

val: ’g’

next: null

random: D}

-----------

| |

| V

A -> D -> G -> null

-------------

| |

| V

A' -> D' -> G' -> null

- 0of 0 votes
Explain in detail about your favourite android api.

- 1of 1 vote
I get a chance to talk to Facebook software engineer during my android engineer interview. He asked me couple of question about native android like diff between views and fragment, mutable and immutable string, diff between string builder and string and a programming question convert int into words.

- 1of 1 vote
I got my interview yesterday and the problem they asked me was: Giving a method intToEnglish that receives an int as a parameter, how do you return its representation in english words. The number can be of any size but no more than around 2 billion since the parameter is an int 2ˆ32

- 0of 0 votes
Given an Array of N elements and Integer K, write a function that returns true if the sum of any 2 elements of Array is K, false otherwise.

- 0of 0 votes
Given the linked list is sorted, implement a method for insert and element in such a way that the list remain sorted.

- 0of 0 votes
Implement a linked list and all its basic operations (add, delete, remove and insert)

- 0of 0 votes
You are given an integer N. Write a code to calculate 1! - 2! + 3! ... up to N terms.

- 1of 1 vote
You are given a function F6() which return 1,2,3,4,5,6 randomly with equal probability. Implement a new function F12() which returns 1 to 12 randomly with equal probability using F6().

- 0of 0 votes
Given an arithmetic expression, write a program to find the value of the expression. Only binary operations that are allowed are +,-,*,/. Also assume that all parentheses are well matched.

Note that the use of eval() is forbidden

Input format :There is a single positive integer T on the first line of input . It stands for the number of expressions to follow.

Next T lines followed by expression

Output format : For each expression print the value of expression

3

19 + 12 / 4 - ((4 - 7) * 3 / 1)

1 + (2 - 3) * 4 + 5 - 6 * 8 - (18 * 12 * 13) - (11 / (5 + 2 + 4))

((2 + 4) / 3 - 2 + 1)

Output:

31

-2855

1

- 0of 0 votes
Write a method given a string with unbalanced parenthesis, the output should return a string with balanced parenthesis.

Ex: (a(b(c)de should change to (a(b(c)d)e)

- 0of 0 votes
Tell me about one Android API that you had difficulty using in a project and how did you resolve that Issue.

- 0of 0 votes
Find the uncommon elements from 2 lists.

I/P :

List 1 : 1, 2, 3, 4, 5

List 2 : 3, 4, 5, 6, 7

O/P : 1, 2, 6, 7

I/P :

List 1 : 1, 2, 3, 1, 5

List 2 : 3, 4, 5, 6, 7

O/P : 1, 1, 2, 6, 7

Most probably using space O(n)

- 0of 0 votes
Imput Output

81 --> 9^2 --> 1 (as its only 9)

82 --> 9^2 + 1^2 --> 2 (as 9 & 1)

6 ->> 2^2 + 1^2 + 1^2 --> 3 (as 3 elements 9, 1 & 1)

SO how can we solve this question

- 2of 2 votes
A museum was represented by a square matrix that was filled with O, G, and W where O represented open space G represented guards, and W represented walls. Write a function that accepts the square matrix and returns another square matrix where all of the O's in the matrix are replaced with the number of how many spaces they are away from a guard, without being able to go through any walls.

- 1of 1 vote
Integer Array Ques:

Given an integer array of variable length like so [9, 8, 8, 3] where each item in array could be 0 to 9, write a function that would take would interpret the array [9, 8, 8, 3] as a number 9883 and increment it by 1. The return of the function would be an integer array containing the addition like so [9,8,8,4]. No zeros in the first position like [0,1,2,3]. I initially suggested a possible solution of process to convert the integer array to String then convert to Integer or Long and then do the addition of 1 and then convert it back to integer array. That is not allowed when the interviewer change the ques. to not allow that.

- 0of 0 votes
tower Of Hanoi using priority queue

- 6of 6 votes
Phone Interview with Collabedit.

/** Compute the value of an expression in Reverse Polish Notation. Supported operators are "+", "-", "*" and "/".

* Reverse Polish is a postfix mathematical notation in which each operator immediately follows its operands.

* Each operand may be a number or another expression.

* For example, 3 + 4 in Reverse Polish is 3 4 + and 2 * (4 + 1) would be written as 4 1 + 2 * or 2 4 1 + *

*

* @param ops a sequence of numbers and operators, in Reverse Polish Notation

* @return the result of the computation

* @throws IllegalArgumentException ops don't represent a well-formed RPN expression

* @throws ArithmeticException the computation generates an arithmetic error, such as dividing by zero

*

* <p>Some sample ops and their results:

* ["4", "1", "+", "2.5", "*"] -> ((4 + 1) * 2.5) -> 12.5

* ["5", "80", "40", "/", "+"] -> (5 + (80 / 40)) -> 7

*/