MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / f

Function f

CSES/DP/RemovingDigits.cpp:19–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17tcU> T min(T &a, T b) { return a > b ? b : a;}
18
19int f(int N,vector<int> &dp) {
20 if (N <= 0) return 0;
21
22 if (dp[N] != -1) return dp[N];
23
24 int ans = INT_MAX;
25 int temp = N;
26 while (temp != 0){
27 int rem = temp % 10;
28 if (rem != 0) {
29 int ways = f(N-rem,dp) + 1;
30 ans = min(ans,ways);
31 }
32 temp/=10;
33 }
34 return dp[N] = ans;
35}
36
37void solve() {
38 int N; cin >> N;

Callers 1

solveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected