top of page
Search
ArrayList Class Collection Java
ArrayList Class An ArrayList is like an array, which can grow in memory dynamically.Memory is dynamically allotted and re-allotted to...

Abhinaw Tripathi
Jun 17, 20161 min read
4 views
0 comments
Amazon Interview Question: Assume you have a method isSubstring which checks if one word is a substr
Let say you have two string s1 and s2 ,write code to check if s2 is a rotation of s1 using only one call to isSubstring(eg. "WaterBottle"...

Abhinaw Tripathi
May 25, 20161 min read
104 views
0 comments
Very Common Problem on Matrix,if an element in an MXN matrix is 0,its entire row and column are set
Solution: public void setZero(int[][] matrix) { boolean[] row= new boolean[matrix.length]; boolean[] row= new...

Abhinaw Tripathi
May 25, 20161 min read
4 views
0 comments


Write a method to rotate the image by 90 degree.(In place operation is required).
Let say you have an image represented by an NXN matrix where each pixel in the image is 4 byte.So rotate this image in place by 90...

Abhinaw Tripathi
May 25, 20161 min read
3 views
0 comments
Write a method to perform basic string compression eg. aabcccccaaa.Should become the ouput a2b1c5a3.
Bad Solution: public String compressBad(String str) { String mystr= ""; char last=str.charAt(0); int count = 1; for(int i=1; i<...

Abhinaw Tripathi
May 25, 20161 min read
13 views
0 comments
Write a method to replace all spaces with %20 in a String.(Note-Perform in place operation only.)
public void replaceSpaces(Char[] str, int length) { int spaceCount=0; int newLength,i; for(i=0;i<lenght;i++) { if(str[i] == ' ') {...

Abhinaw Tripathi
May 25, 20161 min read
6 views
0 comments
How will you check,given two strings are permutation of the other.
Example: "god" permutation will be "dog" Solution: public String sort(String s) { char[] content = s.toCharArray();...

Abhinaw Tripathi
May 25, 20161 min read
2 views
0 comments
Programming Questions on String and its Best Solution with its complexity
Question: Write an algorithm to find if a string has all unique characters.what if you cannot use additional data-structure?. Solution: i...

Abhinaw Tripathi
May 25, 20161 min read
5 views
0 comments
bottom of page