Engineering Blog 💻

Welcome to my software engineering blog! I’m currently studying leetcode (algorithms & data structures) and system design. As I go through this process, I will be publishing my study notes. Please reach out on Twitter or LinkedIn if you found something helpful, discovered a mistake, or if you would like to chat!

Leetcode 3: Longest Substring Without Repeating Characters

Problem Statement Description Given a string my_str, find the length of the longest substring without repeating characters. Examples Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3....

April 16, 2023 · 2 min · 394 words · Me

Leetcode 973: K Closest Points to Origin

Problem Statement Description Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x1 - x2)2 + (y1 - y2)2). You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in)....

April 15, 2023 · 3 min · 499 words · Me

Leetcode 238: Product of Array Except Self

Problem Statement Description Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation. Examples Example 1: Input: nums = [1,2,3,4] Output: [24,12,8,6] Example 2: Input: nums = [-1,1,0,-3,3] Output: [0,0,9,0,0] Constraints 2 <= nums....

February 20, 2023 · 3 min · 509 words · Me

Leetcode 53: Maximum Subarray

Problem Statement Description Given an integer array nums, find the subarray with the largest sum, and return its sum. Examples Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The subarray [4,-1,2,1] has the largest sum 6. Example 2: Input: nums = [1] Output: 1 Explanation: The subarray [1] has the largest sum 1. Example 3: Input: nums = [5,4,-1,7,8] Output: 23 Explanation: The subarray [5,4,-1,7,8] has the largest sum 23....

January 24, 2023 · 4 min · 692 words · Me

Dynamic Programming

Definition Dynamic Programming is a very powerful programming paradigm that can be employed to find optimal solutions to problems that possess the following properties: overlapping subproblems and optimal substructure. Overlapping subproblems A problem can be decomposed into smaller subproblems than can be reused multiple time to construct the overall solution The solutions to subproblems are often memoized to avoid re-work and improve time complexity Solutions to subproblems are reused more than once by subsequent solutions Optimal substructure The optimal solution to a problem can be constructed from the optimal solution of overlapping subproblems....

January 23, 2023 · 2 min · 343 words · Me