- Read the question.
- Read the question complemently.
- Understand what is needed to be done?
- Something to be returned or done in place?
- Confirm understanding.
- Pick a simple example case and write down the expected outcome and confirm if the understanding is correct.
- Ask clarification questions.
- Prepare test cases.
- Come up with brute force solution.
- Develop an optimised solution.
-
What is the type of data stored in the array?
- If the data type is integers, then it contains positive, negative and zeros.
-
Is the array sorted?
-
Is the array comprised of unique elements?
-
Can the array be modified?
- If the question demands "in-place" logic, it means array must be modified.
-
Can the array be empty?
| Case | Array |
|---|---|
| Empty Array | [] |
| Array with single element | [100] |
| Array with positive elements | [1,2,3] |
| Array with dupliates | [1,2,2,4] |
| Array with polarity | [-1,0,1] |
Matrix is typically a 2D array.
-
What is the minimum and maximum dimensions of the givem
m*nmatrix?- Example answer:
1 <= m, n <= 200
- Example answer:
-
Any input constraints on the element, data type and values?
- Example answer:
-2^31 <= matrix[i][j] <= 2^31 - 1
- Example answer:
-
Do we have the liberty to modify the type and value of the elements?
- Example answer: Matrix must contain integer types, values can be modified.
-
Can the matrix be empty?
- Example answer: No, at the very least matrix contains only 1 cell.
| Case | Matrix |
|---|