Skip to content
1. Constraints:
Input:
- Data Structure of Input and Limits/Constraints on Input
- Empty, Null
- Numeric – Integer/Long, double/float, Negative/Positive, Zero, Duplicates, SORTED ? MIN and MAX Value allowed
- Sting – ASCII, UNICODE, English alphabets(a-z), case(lowercase/uppercase), SORTED (lexicographically) ?
- Linked List – Single/Double, Node values, size available, head and/or tail present, Cycle ?
- Tree – Binary/N-ary, BST, Parent, Node(Key), Duplicates ?
- Graph – Directed/Undirected, Connected, Cycle, Weighted ? Input type adj list, adj matrix, edges etc. ?
- Streaming or Fixed size input ?
- Limits/Constraints on Input
- Can Input be Modified ?
Output:
- Data Structure of Output and Limits/Constraints on Input
- Output sorted ? number sort ? string sort ?
- how to handle empty or null or base cases ?
- New Object Creation ? In Place ?
High Level:
- How many times will it (method or class) be called ?
- How will it (method or class) be accessed ?
- Single Core enough to process ?
- Enough Memory Available ?
- Distributed ?
- Expected Time and Space Complexity ? (Debatable to ask or not .. could ask diplomatically)
2. Test Cases:
- Come up with new Test cases
- large size
- small size
- null or empty
- Think/Discuss/Solve the solution for these Test cases
3. Algorithm :
- Discuss
- Start with brute force approach if possible
- Data structure
- Tradeoff of using 1 data structure over over
- Tradeoff of various ways of data structure traversals (like bfs, dfs …)
- Complexities
- Tradeoff of complexities time n space of one approach over another .. high level only
- DONT FORGET to mention complexity variable name’s meanings like n is for input size .. etc.
- Solve
- Solve using all the test cases … run the algorithm so to speak
- Write
- High level algorithm / pseudocode to refer later when coding
- Various cases if present eg: if else, multiple if’s
4. Coding:
- Modularize code .. methods .. top down approach
- explanative variable names … feel free to use additional variables for readability … duplicate operations like +1 -1 can be saved in a new variable
- Think and write space and time complexity after coding
Resources: