id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
0
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if (y >= x)\n return y - x;\n \n vector<bool> visited(1e4 + 1);\n queue<int> q;\n q.push(x);\n int curr_level = 0;\n int until_next_lvl = 1;\n while (!q.empty()...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
0
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n vector<int> vis(x+11,0);\n if(y>=x) return y-x; \n\n queue<pair<int,int>> q;\n q.push({0,x});\n while(!q.empty()){\nint val = q.front().first;\nint nd = q.front().second;\nq.pop();\nif(nd==0) cont...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
0
{ "code": "class item {\npublic:\n int val;\n int dep;\n\n item(int a, int b) : val(a), dep(b) {};\n};\n\nclass Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n int cnt[10005] = { 0, };\n\n for (int i = 0; i < 10005; i++) cnt[i] = INT_MAX;\n\n queue<item> q1;\n...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(y>=x) return y-x;\n int upper = x*2;\n vector<int> minStep(upper, INT_MAX);\n \n queue<int> bfsQ;\n bfsQ.push(x);\n minStep[x] = 0;\n\n while(!bfsQ.empty()) {\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "#include <vector>\n#include <queue>\n#include <climits>\n\nclass Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if (x == y) return 0;\n if (x <= 0 || y <= 0 || x > 10000 || y > 10000) return -1;\n\n // Initialize a vector to track visited states\n st...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n \n int n = max(2*x+1, y+1);\n vector<int> dp(n, 0);\n queue<pair<int, int>> q;\n q.push({x, 0});\n dp[x] = 1;\n\n while (!q.empty()) {\n\n auto [z, ops] = q.front();...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n \n int n = max(2*x+1, y+1);\n vector<int> dp(n, 0);\n queue<pair<int, int>> q;\n q.push({x, 0});\n dp[x] = 1;\n\n while (!q.empty()) {\n\n auto [z, ops] = q.front();...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(y>x)return y-x;\n queue<pair<int,int>>q;\n unordered_map<int,bool>vis;\n q.push({x,0});\n vis[x]=true;\n while(!q.empty()){\n int sz=q.size();\n while(s...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "// Constraints:\n// 1 <= x, y <= 10^4\n\nclass Solution\n{\npublic:\n int minimumOperationsToMakeEqual(int x, int y)\n {\n // Use BFS to find the minimum number of operations\n // 17 ms 58.85 %, 16.15 MB 67.39 %\n if (x <= y)\n {\n return (y - x);\n }\n\n...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(y>=x)\n return y-x;\n unordered_map<int,int>mp;\n queue<pair<int,int>>q;\n q.push({x,0});\n while(!q.empty())\n {\n int a=q.front().first;\n int c=q.fr...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(x<=y)return y-x;\n queue<pair<int,int>>q;\n unordered_map<int,int>vis;\n vis[x]=1;\n q.push({x,0});\n while(q.front().first!=y)\n {\n pair<int,int> p=q.front();\n...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(x<y) return (y-x);\n queue<int> q;\n map<int,int> mpp;\n q.push(x);\n mpp[x] = 1;\n int lvl =0;\n int U = x + (x - y);\n\n while(!q.empty()){\n int size =...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n unordered_map<int, int> mem;\n int minimumOperationsToMakeEqual(int x, int y) {\n if(x<=y){\n return y-x; //since can't modify y\n }\n mem[y]=0;\n return helper(x,y, x);\n }\n int helper(int cur, int y, int orig_x){\n // ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<int> q;\n q.push(x);\n int level = 0;\n unordered_map<int, int> mp;\n while (!q.empty()) {\n int sz = q.size();\n while (sz--) {\n int num = q.fron...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
1
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(y>=x) return y-x;\n queue<pair<int,int>> q;\n unordered_map<int,bool> vis;\n unordered_map<int,int> diss;\n q.push({x,0});\n vis[x]=1;\n diss[x]=0;\n while(!q.empty()){...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n unordered_set<int> vis;\n queue<pair<int, int>> q;\n q.push({x, 0});\n vis.insert(x);\n while (!q.empty())\n {\n auto curr = q.front();\n q.pop();\n \...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n unordered_set<int> vis;\n queue<pair<int, int>> q;\n q.push({x, 0});\n vis.insert(x);\n while (!q.empty())\n {\n auto curr = q.front();\n q.pop();\n \...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<int> q;\n q.push(x);\n vector<bool> vis((int)1e5, false);\n vis[x]=true;\n int steps=0;\n if(y>=x){\n return y-x;\n }\n while(!q.empty()){\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n struct comp{\n bool operator()(const pair<int,int>& p1, const pair<int,int>& p2){\n return p1.first > p2.first;\n }\n };\n int minimumOperationsToMakeEqual(int x, int y) {\n priority_queue<pair<int,int>,vector<pair<int,int>>,comp> q;\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if (x == y)\n return 0;\n unordered_map<int, int> mp;\n queue<int> q;\n q.push(x);\n mp[x] = 0;\n while (!q.empty()) {\n int s = q.size();\n for (int ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "#include <unordered_map>\n#include <queue>\n#include <algorithm>\n\nclass Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if (x == y) return 0;\n \n std::unordered_map<int, int> dp; // Stores minimum steps to reach each number\n std::queue<int> q; // ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n \n if(x == y) return 0;\n \n queue<int>q;\n unordered_map<int,int>m;\n q.push(x);\n m[x] = 1;\n \n int ans = 0;\n while(q.size()>0){\n int ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n unordered_map<int, int> dist;\n queue<int> q;\n\n q.push(x);\n dist[x] = 0;\n\n while (!q.empty()) {\n int curr = q.front();\n q.pop();\n int steps = dist[cu...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n \n if(x <= y)\n return (y-x);\n \n queue<vector<int>>q;\n \n unordered_set<int>visited;\n \n q.push({x,0});\n\n while (!q.empty())\n {\n...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<int> q;\n q.push(x);\n int steps = 0;\n int cnt = 5;\n unordered_set<int> visi;\n while(!q.empty()){\n int sz = q.size();\n while(sz--){\n i...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<int> q;\n q.push(x);\n map<int,bool> vis;\n int level=0;\n while(!q.empty()){\n int n=q.size();\n for(int i=0;i<n;i++){\n int num=q.front();\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
2
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<int> q;\n q.push(x);\n map<int,bool> vis;\n int level=0;\n while(!q.empty()){\n int n=q.size();\n for(int i=0;i<n;i++){\n int num=q.front();\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "#include <queue>\n#include <unordered_map>\n#include <climits>\nusing namespace std;\n\nclass Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n // Edge case: if x is already y\n if (x == y) return 0;\n\n // Queue for BFS (pair of current value and number of op...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n // idea is to use bfs, try all possible combos\n // and keep track of #steps needed to get to the next set of combos\n\n // if x < y, the only way to get to y is to increment by 1, y-x times\n if (...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n unordered_set<int> vis;\n\n int minimumOperationsToMakeEqual(int x, int y) {\n if (y >= x) return y - x;\n queue<vector<int>> q;\n q.push({x, 0});\n while (!q.empty()){\n vector<int> cur = q.front(); q.pop();\n if (vis.find...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n unordered_set<int> nums;\n set<pair<int,int>> pq;\n \n pq.insert({0,x});\n nums.insert(x);\n\n while(!pq.empty()){\n auto item = (*(pq.begin()));\n \n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n set <int> s;\n queue <int> q;\n q.push(x);\n int curr = 0;\n if( x == y )\n return 0;\n\n while( !q.empty()){\n int sz = q.size();\n curr++;\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n set <int> s;\n queue <int> q;\n q.push(x);\n int curr = 0;\n if( x == y )\n return 0;\n\n while( !q.empty()){\n int sz = q.size();\n curr++;\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n int cnt = 0;\n queue<int> q;\n set<int>visited;\n q.push(x);\n\n while(!q.empty()){\n int size = q.size();\n \n while(size--){\n int curr = q....
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if (x == y) return 0;\n\n // Queue to hold pairs of (current_value, operations_count)\n std::queue<std::pair<int, int>> q;\n q.push({x, 0});\n\n // Set to track visited states to avoid cycle...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n\n if (y >= x) return y - x;\n\n queue<pair<int, int>> q;\n q.push({x, 0});\n unordered_set<int> visited;\n\n visited.insert(x);\n\n while (!q.empty()) {\n\n queue<pair<int,...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(x<=y)\n return y-x;\n queue<pair<int,int>>q;\n q.push({x,0});\n map<int,int>m;\n m[x]=1;\n while(!q.empty()) {\n queue<pair<int,int>>t;\n while(!q....
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int bfs_diff_options_poss (int x, int y){\n if (x == y) \n return 0;\n queue<pair<int,int>> q; //value, operations\n q.push({x,0});\n\n unordered_set <int> visited;\n visited.insert(x);\n\n while (!q.empty()) {\n auto[current,o...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "//m0\n//bfs in O(abs(x-y))\n\nclass Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<int> q;\n unordered_set<int> ever2q;\n\n q.push(x);\n ever2q.insert(x);\n\n int level = 0;\n while(q.size()){\n int lsize = q.size();\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "//m0\n//bfs in O(abs(x-y))\n\nclass Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<int> q;\n unordered_set<int> ever2q;\n\n q.push(x);\n ever2q.insert(x);\n\n int level = 0;\n while(q.size()){\n int lsize = q.size();\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(x==y)\n return 0;\n \n unordered_set<int>vis;\n queue<pair<int,int>>q;\n q.push({x, 0});\n vis.insert(x);\n\n while(!q.empty()){\n int curr_val = q.front()...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "#include <queue>\n#include <unordered_set>\n\nclass Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if (x == y) return 0;\n \n std::queue<std::pair<int, int>> q; // {value, operations}\n std::unordered_set<int> visited; \n \n q.push(...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n set<int> st;\n queue<vector<int>> q;\n q.push({x, 0});\n \n //bfs\n while(!q.empty())\n {\n vector<int> curr= q.front();\n q.pop();\n \n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "// Constraints:\n// 1 <= x, y <= 10^4\n\nclass Solution\n{\n#if 1\npublic:\n int solve(int x, int y, vector<int> &dp)\n {\n if (x <= y) return y - x;\n \n if (dp[x] != -1) return dp[x];\n \n //case 1\n int res = abs(x - y); \n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int solve(int x,int y,vector<int>&dp)\n {\n if(x<=y) return y-x;\n if(dp[x] != -1) return dp[x];\n int ans = abs(x-y);\n ans = min(ans,1+x%5+solve(x/5,y,dp));\n ans = min(ans,1+(5-x%5)+solve(x/5+1,y,dp));\n ans = min(ans,1+x%11+s...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n vector<int> dp;\n int solve(int x, int y) {\n if (x <= y)\n return y - x;\n if (dp[x] != -1)\n return dp[x];\n int res = abs(x - y); // case 1\n res = min(res, 1 + x % 5 + solve(x / 5, y)...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\nvector<int> dp;\nint solve(int x, int y){\n ios::sync_with_stdio(false); cin.tie(0);\n if(x <= y) return y - x;\n if(dp[x] != -1) return dp[x];\n int res = abs(x - y); //case 1\n res = min(res, 1 + x%5 + solve(x/5, y)); ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\ntypedef pair<int,int> ip;\n int minimumOperationsToMakeEqual(int x, int y) {\n if(x==y)\n {\n return 0;\n }\n priority_queue<ip,vector<ip>,greater<ip>>pq;\n vector<int>dist(10001,1e9);\n pq.push({0,x});\n dist[x]=0;\n...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "// 5 24 26\n// 1 4 6 23 25 25 27 \n// \n\nclass Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n \n list<int>myQ;\n myQ.push_back( x );\n unordered_set<int>mySet;\n int level = 0;\n while( myQ.size() ){\n int size = myQ.size();...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\ntypedef pair<int,int> ip;\n int minimumOperationsToMakeEqual(int x, int y) {\n if(x==y)\n {\n return 0;\n }\n priority_queue<ip,vector<ip>,greater<ip>>pq;\n vector<int>dist(10001,1e9);\n pq.push({0,x});\n dist[x]=0;\n...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int f(int x,int y,vector<int>&dp){\n if(dp[x]!=-1) return dp[x];\n if(x<=y) return y-x;\n int res = 1e6;\n if (x % 11 == 0) {\n res = 1 + f(x / 11, y,dp);\n } else {\n int rem = x % 11;\n res = min(rem +1+ f(x / 11, y,dp), 11 - rem +1+ f((x...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n vector<int> dp;\n int recur(int x, int y)\n {\n if(x<=y)\n return y-x;\n \n if(dp[x] != -1) return dp[x];\n \n int ans = abs(x-y);\n\n //go to next 11 multiple and then divide by 11\n ans = min(ans, 11 - x%11 +...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n\n vector<int> vis(10001, 1e9);\n \n\n vis[x] = 0;\n priority_queue<pair<int, int>, vector<pair<int, int>>,\n greater<pair<int, int>>>\n q;\n\n q.push({0, x})...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\nint f(int x,int &y, vector<int> &dp){\n if(x==y){\n return 0;\n }\n // if(x <= 0) return INT_MAX;\n if(x<y){\n return y-x;\n }\n if(dp[x]!=-1){\n return dp[x];\n }\n\n int a=1e7;\n int divbyele=1e7;\n if(x%11==0){\n a=1+f(x...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\nint f(int x,int &y, vector<int> &dp){\n if(x==y){\n return 0;\n }\n if(x <= 0) return INT_MAX;\n if(x<y){\n return y-x;\n }\n if(dp[x]!=-1){\n return dp[x];\n }\n\n int a=1e7;\n int divbyele=1e7;\n if(x%11==0){\n a=1+f(x/1...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int solve(int a,int b,vector<int> &dp){\n // cout<<a<<\" \"<<b<<endl;\n if(a<=b)return b-a;\n // if(a==b)return 0;\n if(dp[a]!=1e6)return dp[a];\n int p = 1e6,q=1e6,s = 1e6;\n if(a%11==0)\n p = 1+solve(a/11,b,dp);\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int solve(int x , int &y , vector<int>&dp){\n if(x<y){\n return y-x ; \n }\n if(x==y){\n return 0 ; \n }\n if(dp[x]!=-1){\n return dp[x] ; \n }\n int temp1 = 1e9 ; \n if((x%11)==0){\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\n \npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<pair<int,int>>pq;\n vector<int>dist(max(x,y)+1e4,1e9);\n pq.push({0,x});\n while(!pq.empty()){\n auto it=pq.front();\n pq.pop();\n int number=it.second;\n...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\n \npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<pair<int,int>>pq;\n vector<int>dist(max(x,y)+1e4,1e9);\n dist[x]=0;\n\n // unordered_map<int,int>mp;\n // mp[x]=0;\n pq.push({0,x});\n while(!pq.empty()){\n a...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": " class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n queue<vector<int>> q;\n unordered_set<int> vis;\n q.push({x, 0});\n while (!q.empty()) {\n auto it = q.front();\n q.pop();\n int val = it[0];\n int step...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n vector<int> visited(1e4 + 1);\n queue<vector<int>> q;\n visited[x] = true;\n q.push({x, 0});\n while(!q.empty()) {\n vector<int> temp = q.front();\n q.pop();\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "#include <queue>\n#include <unordered_set>\n\nclass Solution {\npublic:\n vector<int> dp;\nint solve(int x, int y){\n if(x <= y) return y - x;\n if(dp[x] != -1) return dp[x];\n int res = abs(x - y); //case 1\n res = min(res, 1 + x%5 + solve(x/5, y)); ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "const int INF = 1e9 + 7;\nclass Solution {\npublic:\n int dijkstra(vector<vector<int>>& adj, int src, int dest) {\n int n = adj.size();\n vector<int> dist(n, INF);\n queue<vector<int>> q;\n\n q.push({src,0});\n while(!q.empty()) {\n vector<int> cur = q.front...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n int operations = 0;\n vector<int> dp (20001, -1);\n\n queue<int> q;\n q.push(x);\n dp[x] = operations;\n\n while (!q.empty()) {\n operations++;\n int size = q.size();\n\n for...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n vector<int> bfs;\n vector<int> vis(20005,0);\n bfs.push_back(x);\n vis[x] = 1;\n int z;\n for(int i = 0; i < bfs.size(); i++){\n z = bfs[i];\n // printf(\"curren...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
3
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n \n //bfs bfs bfs\n \n vector<int>dist(10012,1e9);\n dist[x]=0;\n \n queue<int>qu;qu.push(x);\n while(!qu.empty()){\n int u=qu.front();qu.pop();\n i...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
0
{ "code": "class Solution {\npublic:\n long long dp[17][2];\n long long f(string&s,int i,bool tight,int limit,string&c,int n,int m){\n if (s.size()<m) return 0;\n if ((i+m)==n) {\n if (tight) {\n for (int j=i;j<n;j++) {\n int lmt=9;\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
0
{ "code": "class Solution {\npublic:\n long long dp[16][2];\n int maxAllowed;\n // index, tight\n long long f(int ind, int tight, string &suffix, string &s){\n if(ind == s.size()){\n return 1;\n }\n\n if(dp[ind][tight] != -1) return dp[ind][tight];\n long long ans = ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
0
{ "code": "typedef long long ll;\nclass Solution {\npublic:\n\t// index, tight\n ll dp[16][2]; \n\t\n ll f(int index, bool tight, int& maxAllowed, string &suffix, string &s){\n // Base case : index out of bound\n if(index == s.size()) \n\t\t\treturn 1;\n\n // already calculated\n if(...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
0
{ "code": "typedef long long int ll;\nll dp[17][2];\nclass Solution {\npublic:\n ll helper(string &s, ll limit, string &s2, ll ind, bool tight, string &temp){\n if(s.length() < s2.length())return 0;\n if(ind == s.length()){\n // cout<<temp<<endl;\n return 1;\n }\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
0
{ "code": "long long dp[16][2][2];\nclass Solution \n{\nprivate:\n long long solve(int i, int low, int high, int &n, int &m, string &a, string &b, string &s, int &limit)\n {\n if(i == n)\n return 1;\n if(dp[i][low][high] != -1)\n return dp[i][low][high];\n int lower_li...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
0
{ "code": "\nusing ll = long long;\nusing namespace std;\n\nclass Solution {\npublic:\n // Function to calculate a^b\n ll pw(ll a, ll b) {\n ll ans = 1;\n while (b--) ans *= a;\n return ans;\n }\n\n // Function to count powerful integers up to n with a given limit and suffix s\n ll...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
0
{ "code": "\nusing ll = long long;\nusing namespace std;\n\nclass Solution {\npublic:\n // Function to calculate a^b\n ll pw(ll a, ll b) {\n ll ans = 1;\n while (b--) ans *= a;\n return ans;\n }\n\n // Function to count powerful integers up to n with a given limit and suffix s\n ll...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
0
{ "code": "class Solution {\npublic:\n\n string st,f;\n\n int n;\n\n int z;\n\n long long dp[21][2][2];\n\n long long rec(int i,int lo,int hi,int limit,string &s){\n if(i==n)return 1;\n if(dp[i][lo][hi]!=-1)return dp[i][lo][hi];\n if(i>=z){\n int dig=s[i-z]-'0';\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
1
{ "code": "class Solution {\npublic:\n\n string st,f;\n\n int n;\n\n int z;\n\n long long dp[21][2][2];\n\n long long rec(int i,int lo,int hi,int limit,string &s){\n cout<<\"i\"<<\" \"<<i<<\" \"<<\"lo\"<<\" \"<<lo<<\" \"<<\"hi\"<<\" \"<<hi<<endl;\n if(i==n)return 1;\n if(dp[i][lo][...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
1
{ "code": "typedef long long int ll;\n\nll dp[2][18];\n\nclass Solution {\n \n int limit;\n int len;\n vector<int> suffix;\n vector<int> max_val;\n \n ll PowerfulIntegers (int ind, bool is_smaller) { \n if (ind == len) return 1;\n if (dp[is_smaller][ind] != -1) return dp[is_sma...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
1
{ "code": "typedef long long int ll;\n\nll dp[2][18];\n\nclass Solution {\n \n int limit;\n int len;\n vector<int> suffix;\n vector<int> max_val;\n \n ll PowerfulIntegers (int ind, bool is_smaller) { \n if (ind == len) return 1;\n if (dp[is_smaller][ind] != -1) return dp[is_sma...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
1
{ "code": "#include <cmath>\n#include <string>\n\n#define ll long long\n\nclass Solution {\npublic:\n ll solve(ll start, ll finish, ll lim, string s) {\n string str = to_string(finish);\n int m = str.size() - s.size();\n ll no = (finish )% static_cast<ll>(pow(10, s.size()));\n\n ll ans ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
1
{ "code": "class Solution {\nprivate:\n long long dp[16][2][2];\n \n long long countValidNum(int ind, bool isLowEq, bool isHighEq, string& low, string& high, int limit, string& s, int n) {\n if(ind == n) {\n return 1;\n }\n\n if(dp[ind][isLowEq][isHighEq] != -1) return dp[ind]...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
1
{ "code": "class Solution {\npublic:\nlong long f=1;\nlong long dp[50][2];\nlong long solve(int i,int cont,string &r,string &s,int l)\n{\n //cout<<r<<endl;\n if(r.length()<s.length())return 0;\n //cout<<r<<\" \"<<s<<endl;\n if(r.length()-i==s.length())\n {\n //cout<<s.length()<<\" \"<<i<<\" \"<<r.length(...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "class Solution {\n int n;\n long long dp[20][2][2];\n long long solve(string& p, string& q, int i, int hi, int lo, string& s, int limit){\n if(i == n) return 1;\n\n if(dp[i][hi][lo] != -1) return dp[i][hi][lo];\n\n int st = 0;\n int en = limit;\n if(hi == 0) en =...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "class Solution {\npublic:\n string a,b;\n long long dp[20][2][2];\n long long rec(int level, int hi, int lo, int limit, string & s)\n {\n if(level >= b.size())\n {\n return 1ll;\n }\n if(dp[level][hi][lo] != -1)\n {\n return dp[level][hi]...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "typedef long long ll;\nclass Solution {\npublic:\n ll help(ll i, ll maxi, ll limit, string s){\n if(maxi < s[i]-'0') return pow(limit+1, s.size()-i);\n ll ans = maxi*pow(limit+1, s.size()-i-1);\n if(i+1 < s.size()) ans+= help(i+1, min(ll(s[i+1]-'0'), limit), limit, s);\n els...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "class Solution {\nprivate:\n long long countPowerfulNums(long long maxNum, int limit, string suff){\n string maxNumStr = to_string(maxNum);\n int maxNumLen = maxNumStr.length();\n int suffLen = suff.length();\n\n if(maxNumLen < suffLen){\n return 0;\n }\n\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "int64_t memoization[17][2];\n\nclass Solution {\npublic:\n // Using Digit DP to count all the Powerful Integers till x\n long long countPowerfulIntegers(long long x, int limit, string suffix) {\n // Convert 'x' to a string representation\n string xStr = to_string(x);\n const int ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "int64_t memoization[17][2];\n\nclass Solution {\npublic:\n // Using Digit DP to count all the Powerful Integers till x\n long long countPowerfulIntegers(long long x, int limit, string suffix) {\n // Convert 'x' to a string representation\n string xStr = to_string(x);\n const int ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "class Solution {\npublic:\n string t;\n long long dp[16][2][2];\n // unordered_map<string, long long> dp; \n\n long long helper(long long i, long long f1, long long f2, string& start, string& finish, long long limit) {\n if (i == finish.size()) return 1;\n\n if(dp[i][f1][f2]!=-1)...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "using LL = long long;\nclass Solution {\npublic:\n long long numberOfPowerfulInt(long long start, long long finish, int limit, string s) {\n return helper(to_string(finish), limit, s) - helper(to_string(start-1), limit, s);\n }\n\n LL helper(string a, int limit, string s)\n {\n if...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "class Solution {\npublic:\n\n long long getNumFromString(string& s)\n {\n // number constructed from s.\n long long num = 0;\n\n // column refers to one's column, ten's columns, ...\n int column = 0;\n \n for(int ii=s.size()-1; ii>=0; --ii)\n {\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "class Solution {\npublic:\n\n long long getNumFromString(string& s)\n {\n long long multiplier = 1;\n long long num = 0;\n for(int ii=0; ii<s.size(); ++ii)\n {\n int index = s.size() - 1 - ii;\n multiplier = pow(10, ii);\n num += ( (s[index...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
2
{ "code": "class Solution {\npublic:\n\n long long getNumFromString(string& s)\n {\n long long multiplier = 1;\n long long num = 0;\n for(int ii=0; ii<s.size(); ++ii)\n {\n int index = s.size() - 1 - ii;\n multiplier = pow(10, ii);\n num += ( (s[index...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "class Solution {\npublic:\nlong long dp[16][2][2];\nstring l,r,temp;\nint len,k;\nlong long rec(int lev, int lt, int rt, int limit){\n if(lev==len-k){\n if(lt==0&&rt==0)return 1;\n if(lt==0){\n string temp2 = r.substr(len-k,k);\n long long x = stoll(temp2);\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "#define ll long long\nclass Solution {\npublic:\n ll n,lim,last;\n string l,r,s;\n ll dp[16][2][2];// 128\n ll rec(int lev,int lt,int rt){\n if(lev==n-s.size()){\n if(lt==0&&rt==0)return 1;\n if(lt==0){\n string t=r.substr(n-s.size(),s.size());\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "class Solution {\npublic:\n long long dp[20][2];\n\n long long solve(string num, string s, int tight, int n, int limit) {\n\n if(num.length() < s.length()) return 0;\n\n if(dp[n][tight] != -1) return dp[n][tight];\n\n int ub = tight ? num[num.length()-n] - '0' : limit;\n\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "class Solution {\nprivate:\n long long solve(int i,bool tight,string &str,int limit,string &s,vector<vector<long long>> &dp){\n if(i==str.length()){\n return 1;\n }\n if(dp[i][tight]!=-1) return dp[i][tight];\n int l ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "class Solution {\npublic:\n #define ll long long\n string finish;\n string start;\n string suffix;\n int limit;\n string convert(ll val,string &target){\n int n = target.size();\n string source = to_string(val);\n int digits = source.size();\n string ans = \"\"...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "class Solution {\npublic:\n vector<int>a,b;\n long long dp[16][2][2];\n int l;\n long long calc(int pos,int f1,int f2,string str)\n {\n if(pos==a.size()) return 1;\n if(dp[pos][f1][f2]!=-1) return dp[pos][f1][f2];\n long long ans=0;\n if(pos<a.size()-str.size()) \...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "class Solution\n{\nprivate:\n set<string> vis;\n int getLen(long long num)\n {\n int len = 0;\n while (num)\n {\n len++;\n num /= 10;\n }\n\n return len;\n }\n\n void solve(int empty, string s, int limit, int start, int end)\n {\n ...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "class Solution {\npublic:\n long dp[17][2];\n long digitDP(int ind, bool is_smaller, string finish, string s, int n, int limit){\n if(ind == n - s.size())\n return is_smaller ? true : finish.substr(n - s.size()) >= s;\n if(dp[ind][is_smaller] != -1)\n return dp[ind...
3,243
<p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p> <p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en...
3
{ "code": "class Solution {\npublic:\n long long dp[17][3];\n long long helper(string upper,int ind, string s,bool tight,int limit)\n {\n if(upper.length()<s.length())return 0;\n if(upper.length()==s.length())\n {\n if(upper<s)return 0;\n return 1;\n }\n ...