Let’s Face DSA Together
Hello builders. I hope you all are doing well. Today I am bringing a new series: Let's Face DSA Together! -A guide for a complete newbie like me. If you…
https://python-hub.com/lets-face-dsa-together/
Hello builders. I hope you all are doing well. Today I am bringing a new series: Let's Face DSA Together! -A guide for a complete newbie like me. If you…
Day 1: Cache-Friendly Arrays, Alternate Elements & Leaders In An Array—DSA Diary Learn why arrays love CPU caches, print alternate elements, and find “leader” values in O(n). Day 1 of…
Here's the question link on LeetCode 53. Maximum Subarray: https://leetcode.com/problems/maximum-subarray/description Brute O(n^2)Optimal - O(n)Why can we not use prefix sums?Why does Kadane's work? Brute O(n^2) Try all possible subarrays using…
Here’s the question link on LeetCode 74. Search a 2D Matrix: https://leetcode.com/problems/search-a-2d-matrix/description Brute O(n*m)Optimal O(log(n*m))Code Lines Explained Brute O(n*m) A brute-force way is to perform an n*m search every time:…
Here’s the question link on LeetCode 54. Spiral Matrix: https://leetcode.com/problems/spiral-matrix/description Brute Force [Space - O(m × n)]Optimal [Space - O(1)] Brute Force [Space - O(m × n)] My first thought…