jeevanus
BAN USER
- 0of 0 votes
AnswersWrite a program to make the following possible with any given tree.
- jeevanus in India for Hydrabad
6
/ \
3 5
/ \ \
2 5 4
/ \
7 4
There are 4 leaves, hence 4 root to leaf paths:
Path Sum
6->3->2 632
6->3->5->7 6357
6->3->5->4 6354
6->5>4 654
Answer = 632 + 6357 + 6354 + 654 = 13997| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersSuggest a Data Structure to do the following opperations with time complexity O(1).
- jeevanus in India for Hydrabad
insert(int element); //insertes an element in O(1);
delete(int element); //deletes an element in O(1);
lookup(); // returns any element in random from the list at O(1);| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 5of 5 votes
AnswersGiven a Sorted integer array which is rotated N number of times. You have no idea what that N is. An element in the array can occur more for any number of time. Write a method to search the position of a given element. If there are more than one of the same element, return the position of the first element.
- jeevanus in India for Microsoft CRM| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm Data Structures Sorting
public class Lookup {
ArrayList<Integer> al = new ArrayList<>();
void insertElement(int value) {
al.add(value);
}
void deleteElement(int value) {
al.remove(value);
}
int lookUp() {
return al.get(new Random().nextInt(al.size()));
}
void printArray() {
System.out.println(al);
}
}
- jeevanus November 24, 2015