Home
CP-Blogs
Cancel

Search in Rotated Sorted Array

Problem Link Brute-Force The problem tells us to find a target value in the array nums which is a sorted array that has been rotated around an unknown pivot. The brute force approach would be to g...

Vacation

Note: This problem is part of the Atcoder Educational Dp Contest Problem Link Brute-Force/Recursive Approach We know that we cannot take any given activity for two or more days in a row. So o...

Unbounded Knapsack

Problem Statement: We are given an array of n items, each with a weight ($\boldsymbol{W_i}$) and a profit ($\boldsymbol{P_i}$),and a bag (aka knapsack) which has a limited capacity of $\boldsymbol{...

Frog 2

Note: This problem is part of the Atcoder Educational Dp Contest Problem Link Brute-Force/Recursive Approach Building from the logic of Frog 1, we know that if a frog can jump k stones ahead ...

Frog 1

Note: This problem is part of the Atcoder Educational Dp Contest Problem Link Brute-Force/Recursive Approach We know that from given h[i], we can only go to either h[i+1] or h[i+2]. If we rev...

Kadane's Algorithm

Problem Statement We are given an array of size n and we need to find the maximum subarray sum. Note: A subarray is a contiguous section of numbers from the original array Given: $A : [ ...

0/1 Knapsack

Problem Statement: We are given an array of n items, each with a weight ($\boldsymbol{W_i}$) and a profit ($\boldsymbol{P_i}$), and a bag (aka knapsack) which has a limited capacity of $\boldsymbol...