Edge cases to consider during problem solving
Here are some edge cases I normally check:
Numbers:
0,positive number,negative number, duplicate numbers, sorted order, empty input, single value input,MIN_INT, MAX_INT, leading zeros, Null
Strings:
null,Non null,empty strings, long string, uppercase,lowercase characters, ascii/unicode, character to find not found, numbers being present, even length/odd length (very important for palindrome)
If limited to a specific set of characters, what happens when some are not in the range
Stack and Queue:
Popping from empty stack/queue
Hashmap:
Getting value of key in a hashmap when the key doesn't exist in hashmap
Sorted:
Ascending or descending
Trees:
Full, Complete, Binary Tree or BST
Graphs:
What type of graph? connectivity and if it's directed or undirected, DAG? Minimum weight cycles? Adj list or matrix?
Some other checks to avoid the errors:
- Return type: are we returning correct return value
- For memory error: Will it fit in memory?
- For TLE: 1000000, while loops running forever (properly incrementing/decrementing pointers)
- For value error: Dividing by zero
- boundary cases
- If you're doing any sorting or anonymous comparator, what happens if two values are equal? Do you then sort based on a second condition?
- What if duplicates are present?
- Are we guaranteed to find a solution? What happens if there are multiple solutions? Which one do we return?
- Will there be any possible empty spaces? Do we trim them or disregard them?
- How will the data be presented/passed in?
Maybe I'm forgetting some other edge cases. Feel free to add to this list if you think of anything is missing.

