You have unread notifications. Click here.

ATM (Memoization Code)

Loading ...
Start Coding
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
int vis[100][1000000];
int solve(vector<int> &x, int y,int i, int sum){
-if( i == x.size() || sum >= y)
--return sum==y;
-if( vis[i][sum] != -1 )
--return vis[i][sum];
-return vis[i][sum] = solve(x,y,i, sum+x[i]) + solve(x,y,i+1, sum);
}
int main() {
-memset(vis, -1 , sizeof(vis));
-vector<int> x={1,2,5};
-int y = 10;
-cout<< solve(x,y,0,0) <<endl;
}

Exercises

English Version
Show Advanced Exercises

Advanced Exercises

Questions

Answer the following questions according to what you learned from the video.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Send

Comments & Feedback

ملحوظة يتم مراجعة التعليقات قبل ظهورها من قبل الإدارة. رجاء عدم كتابة نفس التعليق أكثر من مرة.
Back to Course