Created
October 18, 2023 07:55
-
-
Save bunnykek/e76bc90624223ffe1015c0eb08159be1 to your computer and use it in GitHub Desktop.
One box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You are working in the resource distribution team of your company A One block is a block of data having exactly one resource which has vatus 1 You are given an array | |
// A containing N resource values What is the number of ways to divide the array into continuous blocks such that each block | |
``` | |
int main() { | |
vector<int> v = {0 ,1, 0}; | |
int n = v.size(); | |
vector<int> dp(n+1, 1); | |
for(int i=n-1; i>=0; i--){ | |
int count = 0, sum = 0; | |
for(int k=i; sum<=1 and k<v.size(); k++){ | |
sum+=v[k]; | |
if(sum==1) count += dp[k+1]; | |
} | |
dp[i]=count; | |
} | |
cout<< dp[0]; | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment