gurha.pallav
BAN USERAre you guys (Puneet and SE) missing something ? The problem itself says that we have to find those numbers where B COMES AFTER A IN THE ARRAY. So the approach with BST should solve the problem, do let me know in case I am missing something here.
- gurha.pallav June 22, 2010Hi,
This is pretty good. But was wondering is it possible to solve it in the space complexity of O(1) as now its O(2).
-Pallav
Hi,
The place where you Choose ArrayList over LinkedList are as followed:
1. When you are getting the elements from the ArrayList by index. Which is faster and the complexity is O(1) as it just goes and fetches the element required.
2. When you are always doing insertions from the List at the End, rather than doing insertions and deletions in between the list.
The place where you choose LinkedList over ArrayList is
1. When you are doing lot of insertions and deletions in the List in between. So in the case of LinkedList you just go to that particular location and just change few pointers and your work is done. Whereas in the case of ArrayList after the element is deleted from the ArrayList in between, then the whole list has to be moved to occupy the empty space in case of deletion and to move all the elements in the List one index ahead in case of Insertions.
So, these are the places where you need to choose between ArrayList And LinkedList.
-Pallav
Its depends upon the OS
- gurha.pallav June 24, 2010Windows:
Ctrl + break gives you the complete thread dump
Linux:
Kill -3