Amazon Interview Experience | Set 425
Round 1: Technical Face 2 Face.
- Write a program to find the range of majority elements in array(non-descending)?
- Write program to print all the permutation of String? Example Input : AB, Output : {$, “A”, “B”, “AB”};
- Write program to transform a tree from give tree, such that each node will have the sum of child nodes plus itself.(Write recursive funciton)
To best of me i have given answer to all the three programs(little doubtful with 2nd one).
No Selected. 🙁
For first question my approach was:
public class MajorityRange { public static void main(String args[]) { int number[] = { 1, 3, 3, 3, 3, 3, 4 }; int size = number.length; int start = 0; int end = size - 1; int count = 1; for (int i = 1; i < size; i++) { if (number[i] != number[i - 1]) { if (count > size / 2) { end = i - 1; } else { start = i; } } else { count++; } } System.out.println("Start = " + start + "End = " + end); } } |
chevron_right
filter_none
Explanation: Solved in O(n) time complexity. In order to improve the complexity we can use divide and conquer strategy(Modified version of Jump Search or interpolation Search)
Recommended Posts:
- Amazon Interview Experience | Set 167 (SDE I for 1 year 6 months experience)
- Amazon Interview Experience | Set 391 (SDE-2, 5.5 years Experience)
- Amazon Interview Experience | Set 242 (1 Year Experience)
- Amazon Interview Experience | Set 243 (2.5 Years Experience)
- Amazon Interview Experience | 401 (3+Years Experience for SDE II)
- Amazon Interview Experience | Set 241 (1.5 years experience)
- Amazon Interview Experience (For Experience - 2.8 yrs) | SDE 1
- Amazon Interview Experience | Set 248 (4.8 Yrs Experience for SDE II)
- Amazon SDE-2 Interview Experience
- Amazon SDE-I Interview Experience
- Amazon Interview Experience | Set 392 (For SDE 2)
- Amazon Interview Experience | Set 299
- Amazon Interview Experience | Set 308 (For SDE)
- Amazon Interview experience | Set 330
- Amazon Interview Experience | Set 434 (For SDE-2)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



