Last active
January 3, 2019 09:47
-
-
Save Akshay090/5cfa8040bece3317abb66b1ade743d32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create hashmap | |
Map<Integer, Integer> map = new HashMap<>(); | |
map.containsKey(target) | |
map.get(target) | |
iterate over each entry in a Map | |
Map<String, String> map = ... | |
for (Map.Entry<String, String> entry : map.entrySet()) | |
{ | |
System.out.println(entry.getKey() + "/" + entry.getValue()); | |
} | |
binary search O(log n) | |
private int bsearch(int[] A, int key, int start) { | |
int L = start, R = A.length - 1; | |
while (L < R) { | |
int M = (L + R) / 2; | |
if (A[M] < key) { | |
L = M + 1; | |
} else { | |
R = M; | |
} | |
} | |
return (L == R && A[L] == key) ? L : -1; | |
} | |
substring() | |
is used for getting a substring of a particular String. There are two variants of this method | |
java.lang.StringBuilder.append() | |
used to append the string representation of some argument to the sequence. | |
There are 13 ways/forms in which the append() method can be used by the passing of various types of arguments | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment