RohitDumbre86
BAN USER- 0of 0 votes
AnswersReturn true if two trees are same
- RohitDumbre86 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersAn array has duplicate elements each elements occurs even number of time except one occurs odd number of times. Print that number. Provide the complexites of the solution
- RohitDumbre86 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersDifference between LinkedList and arraylist as to what are the advantages of LinkedList
- RohitDumbre86 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures
its wise to use level order traversal and compare each time.
- RohitDumbre86 April 11, 2012its wise to use level order traversal and compare each time.
- RohitDumbre86 April 11, 2012We can enhance this question if we say if two trees have billions of nodes how will you compare.
- RohitDumbre86 April 11, 2012Thanks almost missed that approach ,I used hashtable . But never the less i could clear the round
- RohitDumbre86 April 11, 2012Needless to say the question is too easy I guess the interviewer was not prepared
- RohitDumbre86 April 10, 2012int j=0;
String reversed = " ";
for(int i=0;i<string.length();i++){
if(string.charAt(i)==' '){
reversed =string.substring(j, i)+" "+reversed;
j=i;
}
}
public class RemoveDelimiters {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub\
LinkedList<String> list1 = new LinkedList<String>();
list1.add(".");
list1.add(" ");
list1.add("?");
list1.add(",");
createdelimeter("How are you, Mr.X?",list1);
}
public static String createdelimeter(String string, LinkedList<String>list1){
for(int i=0; i<string.length();i++){
if(list1.contains(string.substring(i,i+1)))
string = string.replace(string.charAt(i), '|');
}
System.out.println(string);
return null;
}
}
My approach was that run a loop and put in the hashtable. If number occurs again increment the value.
- RohitDumbre86 April 11, 2012After this run through an enumerator and do a modulus operation.