## tylerDurden

BAN USER- 0of 0 votes

AnswersQ2:Implement T9 moblie phone dictionary .But the problem was just to find all the posible outputs given the the sequence of key pressed.

- tylerDurden in India for Data Storage

My Solution :Recursion

private static String[] mapping = { "ABC", "DEF", "GHI", "JKL", "MNO",

"PQR", "STU", "VW", "XY", "Z*#" };

public static void combinations(int[] number, char[] buf, int numIndex) {

for (int i = 0; i < mapping[number[numIndex]].length(); i++) {

buf[numIndex] = mapping[number[numIndex]].charAt(i);

if (numIndex < number.length - 1) {

combinations(number, buf, numIndex + 1);

} else

System.out.println(buf);

}

}

public static void main(String[] args) {

int num[] = { 0, 1};// { 4, 8, 5, 9, 0, 3, 1, 7,6,2 };

PhoneBook.combinations(num, new char[num.length], 0);

}

He was looking for Trie data structure :(| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes

AnswersIt is my first phone screening, it consists of two questions , first question was pretty simple

- tylerDurden in India for Data Storage

Q1:WAP to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.

My Soluton :Kadane’s Algorithm:

int maxSubArraySum(int a[], int size)

{

int max_so_far = 0, max_ending_here = 0;

int i;

for(i = 0; i < size; i++)

{

max_ending_here = max_ending_here + a[i];

if(max_ending_here < 0)

max_ending_here = 0;

if(max_so_far < max_ending_here)

max_so_far = max_ending_here;

}

return max_so_far;

}| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Arrays

if the max number is zero, the max product is zero

- tylerDurden September 24, 2011Assumption here is that if all numbers are negative I return 0 . If all the numbers are negative then the solution is -maximum number , which is not difficult to find

- tylerDurden September 22, 2011**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

this questions can be best solved by taking logs

- tylerDurden September 24, 20113^20 taking log to the base 10 20*(log 3)=20*0.4771=9.54242509

2^30 taking log to the base 10 30*(log 2)=30*0.3010=9.03089987

so, 3^20 is bigger