1/45
Looks like no tags are added yet.
One loop through a list of n elements
O(n) time.
Two independent nested loops, each over n elements
O(n²) time.
Python set add or membership check
Average O(1) time.
Storing up to n distinct elements in a set
O(n) extra space.
In place algorithm with only a few variables
O(1) extra space.
Why is binary search O(log n)?
Each comparison halves the remaining search range.
Iterative binary search extra space
O(1), using only a constant number of index variables.
Karat coding priority
Get a working solution first; optimize only if time permits.
Before saying a coding solution is complete
Spend 30 to 60 seconds checking edge cases.