## 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

## Leetcode 70: Climbing Stairs

Problem Statement Description You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Examples Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top....

January 14, 2023 · 6 min · 1163 words · Me