Skip to content

Commit 00f4751

Browse files
committed
add searching in a map tip
1 parent b78f39e commit 00f4751

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

notes

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,8 @@ sort(engineers.rbegin(), engineers.rend());
157157
Getting binary representation of dec in string format: one-liner
158158
string binaryRep = bitset<8>(decimalNo).to_string();
159159

160-
When a graph problem involves finding a shortest path, BFS should be used over DFS. This is because with BFS, all nodes at distance x from start will be visited before any node at distance x + 1 will be visited. Once we find the target (end), we know that we found it in the shortest number of steps possible
160+
When a graph problem involves finding a shortest path, BFS should be used over DFS. This is because with BFS, all nodes at distance x from start will be visited before any node at distance x + 1 will be visited. Once we find the target (end), we know that we found it in the shortest number of steps possible
161+
162+
For finding if a key is present in map mp
163+
Please use mp.count(key) instead of
164+
mp.find(key) == mp.end()

0 commit comments

Comments
 (0)