DS approach mind map — [Notes]

Tarun Jain
2 min readAug 6, 2023

--

· #2 — Check constraints is very important
· #5 → Dry run
Develop/Memorize dry run framework for all kind of problems

#2 — Check constraints is very important

🎯 If array is a number → +ve / -ve / 0?

🎯 Power of integer in power2 and power10

2^3.33 = 10
-> 31/3.33 = ~9
-> 32/3.33 = ~9

-2^31 = -10^9
-2^32 = 10^9
494. Target Sum

Input: nums = [1,1,1,1,1], target = 3
Output: 5
Explanation: There are 5 ways to assign symbols to make the sum of nums be target 3.
-1 + 1 + 1 + 1 + 1 = 3
+1 - 1 + 1 + 1 + 1 = 3
+1 + 1 - 1 + 1 + 1 = 3
+1 + 1 + 1 - 1 + 1 = 3
+1 + 1 + 1 + 1 - 1 = 3


Constraints:

1 <= nums.length <= 20
0 <= nums[i] <= 1000
0 <= sum(nums[i]) <= 1000
-1000 <= target <= 1000

------------------------
One of the testcase is

nums = [100]
target = -200

🎯 If String → empty/ null / unicode etc?

#5 → Dry run

When code fails to function properly, this is an excellent opportunity to learn and practise dry run. 💡
🎯 Two mangoes with 1 stone → dry run practise + problem found 😀

Develop/Memorize dry run framework for all kind of problems

  • Recursion
  • DP
  • Graph
  • Binary Search
  • Two Pointer
  • Sliding Window

--

--