File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ // NOTE 1: Arrays.sort, Collections.sort etc use quicksort which is inplace sorting algo. Hence these methods are void
2
+ /*
3
+ * Note 2: While iterating over Collection, if we are making modification to Collection
4
+ * then we sould use Iterator for iterating
5
+ *
6
+ * If we are not making any modification, then we can use get(int index) method
7
+ * Example: List<Meeting> meetings = new ArrayList<Meeting>();
8
+ * int count=0;
9
+ * Meeting curr=null;
10
+ * Meeting prev = meetings.get(0);
11
+ * for(int i=1;i<meetings.size();i++){
12
+ * curr=meetings.get(i);
13
+ * if(curr.start < prev.end)
14
+ * count++;
15
+ * prev=curr;
16
+ * }
17
+ *
18
+ Sources: http://stackoverflow.com/questions/5504570/iterator-vs-for-loop-and-why-iterator-was-introduced-as-we-had-for-loop
19
+ http://stackoverflow.com/questions/2113216/which-is-more-efficient-a-for-each-loop-or-an-iterator
20
+ */
You can’t perform that action at this time.
0 commit comments