Professional Documents
Culture Documents
Important Notes
Important Notes
1. When looking for any balance, or having open or close braces, try using Stack, or else have a counter going up and down in pairs.
2. To find the commonality among different arrays or strings, we can use hash and store the frequency. If there are n array and we
have one integer common to all then frequency of the integer must be equal to n
3. To iterate over all the printable characters and save the frequency of each in the hash map, then I should use the below method
hashMap[(int)s[index]]. I am typecasting so as to get the index in the array where value needs to be stored.
4. We can do Binary search also if the matrix is sorted.
5. Bit operations to check the even odd increases the time efficiency.
6. For array questions see if it can be solved by starting from the end all the way to front
7. Use the two pointers for array sometimes, it helps.
8. Have pound defines for swapping two numbers, finding greatest among two or three number or finding vowel
#define IS_VOWEL(ch) ((ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch
== 'U') ? true:false)
#define SWAP(a, b) \
{\
(*a) ^= (*b); \
(*b) ^= (*a); \
(*a) ^= (*b); \
}