id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n public:\n bool isMatch(const string& s, string p) {\n bool isMatch = false;\n p = regex_replace(p, regex(R\"(\\*+)\"), \"*\");\n p = \"^\" + p + \"$\";\n regex regexPatte... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n bool checkForStar(string p, int x) {\n for (int i=x+1; i < p.size(); i+=2) {\n if (p[i] != '*') return false;\n }\n if (p[p.size()-1] != '*') return false;\n\n return true;\n }\n bool fn(string s, string p, int x, int y, vector<vec... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n unordered_map<string, int> memo;\n return dp(memo, s, p, 0, 0);\n }\n\n bool dp(unordered_map<string, int>& memo, const string& s, const string& p, int i, int j) {\n int m = s.length();\n int n = p.length(... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<string, unordered_map<string, bool>> map;\n\n bool isMatch(string s, string p) {\n if (s.size() == 0 && p.size() == 0)\n return true;\n if (s.size() > 0 && p.size() == 0)\n return false;\n if (map[s].find(p) != map[s... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "#include <queue>\nclass Solution {\npublic:\n bool CorrectCh(int idx_s, int idx_p) {\n return s_[idx_s] == p_[idx_p].first || p_[idx_p].first == '.';\n } \n void MakeStep(int idx_s, int idx_p) {\n if (idx_p + 1 < p_.size() && p_[idx_p+1].second) {\n q_.push(std::make_pair(... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<string, unordered_map<string, bool>> map;\n\n bool isMatch(string s, string p) {\n if (s.size() == 0 && p.size() == 0)\n return true;\n if (s.size() > 0 && p.size() == 0)\n return false;\n if (map[s].find(p) != map[s... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dp; // Memoization table\n \n bool f(int i, int j, string p, string s) {\n // Base Case: If both strings are fully traversed\n if (j < 0 && i < 0) {\n return true;\n }\n \n // Base Case: If pattern is exh... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n // A map to store results for the subproblems (memoization)\n unordered_map<string, bool> memo;\n \n bool isMatch(string s, string p) {\n return matchHelper(s, p, 0, 0);\n }\n \n bool matchHelper(const string& s, const string& p, int i, int j) {\n ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n\n vector<vector<int>> dp;\n bool rec(string s, string p,int n,int m,int i,int j) {\n if (i < 0 && j < 0) return true;\n if (j < 0) {\n return false;\n }\n if (i < 0) {\n return p[j] == '*' ? rec(s,p,n,m,i,j-2): false;\n ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dp;\n bool rec(string s, string p,int i,int j){\n if(i<0 && j<0){\n return true;\n }\n if(i<0 && p[j]=='*'){\n return rec(s,p,i,j-2);\n }\n if(j<0 || i<0){\n return false;\n }\n ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "#include <string>\n#include <vector>\n#include <unordered_map>\n\nclass Solution {\npublic:\n bool isMatch(string& s, string& p) {\n memo.clear(); \n return isMatchHelper(s, p, 0, 0);\n }\n\nprivate:\n unordered_map<string, bool> memo;\n\n bool isMatchHelper(string& s, string& p, ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n bool isAllStars(string p, int ind)\n {\n if(ind & 2 == 0)\n return false;\n while(ind >= 0)\n {\n if(p[ind] != '*')\n return false;\n ind -= 2;\n }\n return true;\n }\n\n bool isPatter... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int solve(vector<vector<int>> &dp,string s,string p,int i,int j){\n if(i==-1 && j==-1){\n return true;\n }\n if(i==-1 && j>=0){\n while(j>=0){\n if(p[j]=='*'){\n j=j-2;\n }\n ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n // bool solve(string s , string p , int i , int j , vector<vector<int>>&dp){\n // // both strings traversed\n // if(i<0 && j<0){\n // return true;\n // }\n // // string s is left\n // if(i>=0 && j<0){\n // return false;... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int solve(vector<vector<int>>&grid,int i,int j,string s,string p){\n if(i>=s.size() && j>=p.size())return 1;\n if(j>=p.size())return 0;\n if(i>=s.size()){\n if(j!=p.size()-1 && p[j+1]=='*')return solve(grid,i,j+2,s,p);\n return 0;\n ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n\n bool chk( vector<vector<int>> & dp, string s, string p, int index1, int index2){\n if(index2 < 0){\n return index1<0;\n }\n\nif(dp[index1+1][index2+1]!=-1){\n return dp[index1+1][index2+1];\n}\n if(index2 >0 && p[index2]=='*'){\n return dp[index1+1][in... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n\n bool chk( vector<vector<int>> & dp, string s, string p, int index1, int index2){\n if(index2 < 0){\n return index1<0;\n }\n\nif(dp[index1+1][index2+1]!=-1){\n return dp[index1+1][index2+1];\n}\n if(index2 >0 && p[index2]=='*'){\n return dp[index1+1][in... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\nprivate:\n bool fn(string s, string p, int i, int j, vector<vector<int>> &dp) {\n if (j == -1) {\n return i == -1; \n }\n if (i == -1) {\n if (p[j] == '*') {\n return fn(s, p, i, j - 2, dp); \n }\n return f... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int fun(int i,int j,string pattern,string str,vector<vector<int>>& dp){\n if(i==0 and j==0)\n return true;\n else if(i==0 and j>0)\n return false;\n else if(i>0 and j==0)\n {\n if(pattern[i-1]=='*')\n ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n // map<pair<int,int>,bool> mem;\n int dp[21][21];\n bool check(string s,string p, vector<bool>& isst,int i,int j){\n // if(mem.find({i,j})!=mem.end()) return mem[{i,j}];\n if(dp[i][j]!=-1) return dp[i][j];\n if(i==s.length()){\n if(j==p.l... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n map<pair<string,string>,bool> mem;\npublic:\n bool isMatch(string s, string p) {;\n if(mem.find({s,p})!=mem.end()) return mem[{s,p}];\n\n if(s.size()==0 && p.size()==0) return true;\n if(s.size()==0 && p.size()>=2 && p[1]=='*') return mem[{s,p}]=isMatch(s,p.sub... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n\n bool regex_recursive(string s, string p, int i, int j, string prev)\n {\n bool output;\n if(i==s.size())\n {\n if(j==p.size())\n return true;\n }\n if(j==p.size())\n {\n return false;\n }\n c... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n\n bool regex_recursive(string s, string p, int i, int j, string prev)\n {\n bool output;\n if(i==s.size())\n {\n if(j==p.size())\n return true;\n }\n if(j==p.size())\n {\n return false;\n }\n c... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int n=0;\n int m=0;\n vector<int> cns;\n int dp[25][25];\n vector<bool> consec;\n \n bool solve(int i,int j,string s,string p){\n if(j>=m){\n return (i>=n)? true:false;\n }\n if(i>=n){\n bool isThereAnyNonStarCharAh... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n \n bool findAll(vector<vector<int>>&dp,string s, string p, int a, int b){\n if(a<0&&b<0)\n return true;\n \n if(a<0){\n if(p[b]!='*')\n return false;\n else\n return findAll(dp,s,p,a,b-2);\... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "int dp[21][21];\nclass Solution {\n bool solve(string s, string p, int i, int j) {\n if(dp[i][j]!=-1)\n return dp[i][j];\n if (i >= s.length() && j >= p.length())\n return dp[i][j]=true;\n if (j >= p.length())\n return dp[i][j]=false;\n bool matc... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<string, bool> memo;\n bool isMatch(string s, string p) {\n string key = s + \"____\" + p;\n if (memo.find(key) != memo.end()) {\n return memo[key];\n }\n\n auto isCharOrDot = [](const char &s) -> bool {\n retu... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<string, bool> memo;\n bool isMatch(string s, string p) {\n string key = s + \"____\" + p;\n if (memo.find(key) != memo.end()) {\n return memo[key];\n }\n\n auto isCharOrDot = [](const char &s) -> bool {\n retu... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic: \n bool check(string p,int i)\n {\n for(int j=0;j<=i;j++)\n {\n if(p[j]!='.')\n {\n return false;\n }\n }\n return true;\n }\n bool solve(int i,int j,string s,string p,vector<vector<int>>&dp)\n... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int solve(int i, int j, string A, string B, vector<vector<int>> &dp)\n {\n if(i<0 && j<0) return 1;\n if(j<0) return 0;\n if(i<0)\n {\n //if(B[j]=='*') return solve(i, j-2, A, B);\n while(j>=0)\n {\n ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n int dp[21][21];\n private:\n bool solve(string s,string p,int n,int m){\n if(n<0&&m<0) return true;\n if(m<0&&n>=0) return false;\n if(n<0){\n for(int i=m;i>=0;i-=2){\n if(p[i]!='*') return false;\n }\n return ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int solve(int i, int j, string A, string B, vector<vector<int>> &dp)\n {\n if(i<0 && j<0) return 1;\n if(j<0) return 0;\n if(i<0)\n {\n //if(B[j]=='*') return solve(i, j-2, A, B);\n while(j>=0)\n {\n ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n int dp[21][21];\n private:\n bool solve(string s,string p,int n,int m){\n if(n<0&&m<0) return true;\n if(m<0&&n>=0) return false;\n if(n<0){\n for(int i=m;i>=0;i-=2){\n if(p[i]!='*') return false;\n }\n return ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int dp[21][21];\n\n bool isMatch(string s, string p) {\n memset(dp, -1, sizeof(dp));\n return match(s, p, 0, 0);\n }\n\n bool match(string s, string p, int x, int y) {\n if(dp[x][y] != -1) return dp[x][y];\n\n if(x >= s.size() || y >= p.si... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\n\npublic:\n\n bool isMatch(string s, string p) {\n\n // Create a map to store computed results\n\n unordered_map<string, bool> memo;\n\n return isMatchHelper(s, p, memo);\n\n }\n\nprivate:\n\n bool isMatchHelper(const string& s, const string& p, unordered_map... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n bool f(int i, int j,int n, int m, string s, string p,vector<vector<int>>&dp){\n if(i>=n && j>=m)return true;\n if(j>=m)return false;\n \n if(dp[i][j] != -1)return dp[i][j];\n int match = i < n && (s[i]==p[j] || p[j] == '.');\n if(j+1 ... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "\nclass Solution {\npublic:\n bool isMatch(string s, string p) {\n // Create a map to store computed results\n unordered_map<string, bool> memo;\n\n return isMatchHelper(s, p, memo);\n }\n\nprivate:\n bool isMatchHelper(const string& s, const string& p, unordered_map<string, b... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n // Top Down Dynamic Programming Approach\n\n // if j >= len(p) --> no match\n // if i >= len(s) --> Still Possible match: i.e s= \"a\", p = \"a*b*\"\n // p[j] == '.' or s[i] == p[j] --> (i+1, j+1)\n // match if i < len(s) and (s[i] == p[j] or p[j] == '.')\n //... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n // Top Down Dynamic Programming Approach\n\n // if j >= len(p) --> no match\n // if i >= len(s) --> Still Possible match: i.e s= \"a\", p = \"a*b*\"\n // p[j] == '.' or s[i] == p[j] --> (i+1, j+1)\n // match if i < len(s) and (s[i] == p[j] or p[j] == '.')\n //... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int isMatch(string s, string p, int sIndex, int pIndex, std::span<std::vector<int>> memo) {\n if (sIndex >= s.length() && pIndex >= p.length())\n return 1;\n \n if (pIndex >= p.length())\n return 0;\n\n if (memo[sIndex][pIndex... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n int isMatch(string s, string p, int sIndex, int pIndex, std::span<std::vector<int>> memo) {\n if (sIndex >= s.length() && pIndex >= p.length())\n return 1;\n \n if (pIndex >= p.length())\n return 0;\n\n if (memo[sIndex][pIndex... |
10 | <p>Given an input string <code>s</code> and a pattern <code>p</code>, implement regular expression matching with support for <code>'.'</code> and <code>'*'</code> where:</p>
<ul>
<li><code>'.'</code> Matches any single character.ββββ</li>
<li><code>'*'</code> Matches zero or more... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dp;\n bool f(string s, string p, int i, int j) {\n if (j == p.size())\n return i == s.size();\n if (dp[i][j] != -1)\n return dp[i][j];\n if (j + 1 < p.size() && p[j + 1] == '*') {\n return dp[i][j] =... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "inline bool is_digit(char c) { return c >= '0' && c <= '9'; }\nstd::array<int, 100000> nums;\n\nvoid parse_input_and_solve(std::ofstream& out, const std::string& s) {\n const int N = s.size();\n int left = 0;\n int idx = 0;\n \n // Parsing the input\n while (left < N) {\n if (!is_d... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n#include <algorithm>\n#include <iostream>\n#include <vector>\n\n\ninline bool is_digit(char c) { return c >= '0' && c <= '9'; }\nstd::array<int, 100000> nums;\nvoid parse_input_and_solve(std::ofstream& out, const... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#include <math.h>\nint init = []{\n ios::sync_with_stdio(false); \n cin.tie(nullptr);\n return 0;\n}();\n\ninline bool is_digit(char c) { return c >= '0' && c <= '9'; }\nstd::array<int, 100000> nums;\nvoid parse_input_and_solve(std::ofstream& out, const std::string& s) {\n const int N = s.size(... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "inline bool is_digit(char c) { return c >= '0' && c <= '9'; }\nstd::array<int, 100000> nums;\n\nvoid parse_input_and_solve(std::ofstream& out, const std::string& s) {\n const int N = s.size();\n int left = 0;\n int idx = 0;\n \n // Parsing the input\n while (left < N) {\n if (!is_d... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n#include <algorithm>\n\nstatic const bool Booster = []() {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return true;\n}();\ninline bool is_digit(char c... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n#include <algorithm>\n#include <iostream>\n#include <vector>\n\nstatic const bool Booster = []() {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n#include <algorithm>\n#include <iostream>\n#include <vector>\n\nstatic const bool Booster = []() {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n#include <algorithm>\n#include <iostream>\n#include <vector>\n\nstatic const bool Booster = []() {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n#include <algorithm>\n#include <iostream>\n#include <vector>\n\nstatic const bool Booster = []() {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n#include <algorithm>\n#include <iostream>\n#include <vector>\n\nstatic const bool Booster = []() {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\nstatic const bool Booster = [](){ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); return true;}();inline bool is_digit(char c) { return c >= '0' && c <= '9';}std::array<int, ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "class Solution {\npublic:\n int maxArea(std::vector<int>& height) {\n int n = height.size(); // Correct size assignment\n int i = 0;\n int j = n - 1;\n\n int maxWater = 0;\n\n while (i < j) {\n int w = j - i; // Width of the container\n int h = st... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "class Solution {\npublic:\n int maxArea(vector<int>& height)\n {\n int l=0;\n int r=height.size()-1;\n int mxa=INT_MIN;\n while(l<r)\n {\n int area=min(height[r],height[l]) * (r-l);\n if(height[r]<=height[l]) r--;\n else l++;\n ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "class Solution {\npublic:\n // int maxArea(vector<int>& height) {\n // int rear = height.size()-1;\n // int front = 0;\n // int result = 0;\n // while(rear > front)\n // {\n // int temp = min(height.at(rear),height.at(front)*(rear-front));\n // if... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "class Solution {\npublic:\n int maxArea(vector<int>& height) {\n int i = 0, j = height.size() - 1;\n int ans = 0;\n while (i < j) {\n int t = min(height[i], height[j]) * (j - i);\n ans = max(ans, t);\n if (height[i] < height[j]) \n {\n ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "class Solution {\n public:\n int maxArea(vector<int>& height) {\n int ans = 0;\n int l = 0;\n int r = height.size() - 1;\n\n while (l < r) {\n const int minHeight = min(height[l], height[r]);\n ans = max(ans, minHeight * (r - l));\n if (height[l] < height[r])\n ++l;\n ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "class Solution {\npublic:\n int maxArea(vector<int>& height) {\n int area=INT_MIN;\n int a=0,b=height.size()-1;\n while(a<b){\n int len=min(height[a],height[b]);\n int bre=b-a;\n int ar=len*bre;\n if(ar>area){\n area=ar;\n ... |
11 | <p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
<p>Find two lines that together with the x-axis form a container... | 0 | {
"code": "class Solution {\npublic:\n int maxArea(vector<int>& height) {\n int left = 0 , right = height.size()-1;\n int maxArea = 0;\n while ( left < right ){\n int heights = min(height[left], height[right]);\n int width = right - left;\n maxArea = max(width... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ans;\n while(num>0)\n {\n if(num>=1000)\n {\n num -= 1000;\n ans.push_back('M');\n }\n\n else if(num>=900)\n {\n num ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ans;\n while(num>0)\n {\n if(num>=1000)\n {\n num -= 1000;\n ans.push_back('M');\n continue;\n }\n\n else if(num>=900)\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ans;\n while (num){\n if (num>=1000){\n num -= 1000;\n ans += \"M\";\n } else if (num>=900){\n num -= 900;\n ans += \"CM\";\n } els... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ans;\n while(num>=1000)\n {\n ans+='M';\n num-=1000;\n }\n if(num>=900)\n {\n ans+=\"CM\";\n num-=900;\n }\n if(num>=500)\n {\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string s = \"\";\n while (num > 0) {\n if (num >= 1000) {\n num -= 1000;\n s += \"M\";\n } else if (num - num % 100 == 900) {\n num -= 900;\n s += \"... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n\n string intToRoman(int num) {\n string ans=\"\";\n int count=0;\n if(num/1000){\n count=num/1000;\n while(count){\n ans+='M';\n num-=1000;\n count--;\n }\n }\n if(... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n\n string intToRoman(int num) {\n string ans=\"\";\n int count=0;\n if(num/1000){\n count=num/1000;\n while(count){\n ans+='M';\n num-=1000;\n count--;\n }\n }\n if(... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "#include <bits/stdc++.h>\n\nusing namespace std;\n\nclass Solution {\npublic:\n string intToRoman(int num) {\n int thousand_bit = num / 1000;\n int hundred_bit = (num % 1000) / 100;\n int ten_bit = (num % 100) / 10;\n int one_bit = num % 10;\n\n if (thousand_bit > 0) {... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string s = \"\";\n while (num > 0)\n {\n \n if (num >= 1000){\n num -= 1000;\n s += \"M\";\n }\n else if (num >= 900){\n num -= 900;\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\r\npublic:\r\n string intToRoman(int num) {\r\n string s = \"\";\r\n\r\n if (num >= 1000){\r\n while (num >= 1000){\r\n\r\n num -= 1000;\r\n s += \"M\";\r\n }\r\n }\r\n \r\n if (num >= 900){\r\n wh... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n\n string intToRoman(int num) {\n string ans=\"\";\n int count=0;\n if(num/1000){\n count=num/1000;\n while(count){\n ans+='M';\n num-=1000;\n count--;\n }\n }\n if(... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n std::string s = \"\";\n // s.append(\"a\");\n \n int i = 0;\n int digits[4] = {0,0,0,0};\n \n while(i<4 && num!=0)\n {\n switch(i)\n {\n case 0: digits[0] = num%10;\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n int n=1;\n string res=\"\";\n while(num/(int)pow(10,n)>0)\n {\n n++;\n }\n for(int i=n-1;i>=0;i--)\n {\n int tmp=num/pow(10,i);\n num=num-tmp*pow(10,i);\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string s;\n string d=\"MMMCCCXXXIII\";\n s.append(d,0,num/1000);\n num-= (num/1000)*1000;\n if(num/100==4) s.append(\"CD\");\n else if(num/100==9) s.append(\"CM\");\n else if(num/100< 4) s.append(... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n char romNum[] = {'M','D','C','L','X','V','I'};\n int numbers[4];\n int divide = 1000, i = 0;\n string res = \"\";\n while(num != 0){\n numbers[i] = num / divide;\n num = num % divide;\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n\n int getLastDigit(int num){\n int ans=num;\n while (num){\n ans=num%10;\n num/=10;\n }\n return ans;\n }\n\n string intToRoman(int num) {\n int a[]={1000,500,100,50,10,5,1};\n char b[]={'M','D','C','L','X'... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n vector<int> digits;\n int n = num;\n while (n > 0) {\n digits.push_back(n % 10);\n n /= 10;\n }\n string result;\n while (digits.size() > 0) {\n int digit = digits.back()... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n static const int values[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};\n static const string symbols[] = {\"M\", \"CM\", \"D\", \"CD\", \"C\", \"XC\", \"L\", \"XL\", \"X\", \"IX\", \"V\", \"IV\", \"I\"};\n \n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n static vector<int> val{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};\n static vector<string> sym{\"M\", \"CM\", \"D\", \"CD\", \"C\", \"XC\", \"L\", \"XL\", \"X\", \"IX\", \"V\", \"IV\", \"I\"};\n\n string result=\"... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n static vector<int> val = {1000,900,500,400,100,90,50,40,10,9,5,4,1};\n static vector<string> sym={\"M\",\"CM\",\"D\",\"CD\",\"C\",\"XC\",\"L\",\"XL\",\"X\",\"IX\",\"V\",\"IV\",\"I\"};\n string ans=\"\";\n\n for(int i=... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n std::string res = \"\";\n int romanIntVec[7] = {1,5,10,50,100,500,1000}; \n char romanCharVec[7] = {'I','V','X','L','C','D','M'}; \n while (num) {\n int power = log10(num);\n int closestTenPo... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\n string fun(int n, int m) {\n string ans = \"\";\n if (n == 0) {\n while (m > 0) {\n if (m == 4) {\n ans += \"IV\";\n m -= 4;\n } else if (m == 9) {\n ans += \"IX\";\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(const int num) const {\n constexpr auto max = std::string_view{\"MMMCMXCIX\"}; // 3,999\n std::string res;\n res.reserve(max.size());\n\n const auto generate = [&res](const auto t, const auto indiv, const auto mid, const auto next... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(const int num) const {\n constexpr auto max = std::string_view{\"MMMCMXCIX\"}; // 3,999\n std::string res;\n res.reserve(max.size());\n\n const auto generate = [&res](const auto t, const auto indiv, const auto mid, const auto next... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string symbols[]={\"M\",\"CM\",\"D\",\"CD\",\"C\",\"XC\",\"L\",\"XL\",\"X\",\"IX\",\"V\",\"IV\",\"I\"};\n int nums[]={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n\n string ans=\"\";\n for(int i=0;i<13;i++){\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\nstring alpha(int c){\n if(c==10)\n return \"X\";\n else if(c==20)\n return \"XX\";\n else if(c==30)\n return \"XXX\";\n else if(c==40)\n return \"XL\";\n else if(c==50)\n return \"L\";\n else if(c==60)\n return \"LX\";\n else if(c==70)\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\n\npublic:\n\n string intToRoman(int num) {\n\n string onescounting[] = {\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"};\n\n string tenscounting[] = {\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\"};\n\n string hundredc... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 0 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ones[] = {\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"};\n string tens[] = {\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\"};\n string hrns[] = {\"\",\"C\",\"CC\",\"CCC\"... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n int romanNum[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4 ,1};\n string numRoman[] = {\"M\", \"CM\", \"D\", \"CD\", \"C\", \"XC\", \"L\", \"XL\", \"X\", \"IX\", \"V\", \"IV\", \"I\"};\n\n int i = 0;\n string... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ones[] = {\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"};\n string tens[] = {\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\"};\n string hnds[] = {\"\",\"C\",\"CC\",\"CCC\"... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ans;\n string ones[] = {\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"};\n string tens[] = {\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\"};\n string hrns[] = {\"\"... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ones[] = {\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"};\n string tens[] = {\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\"};\n string hrns[] = {\"\",\"C\",\"CC\",\"CCC\"... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string roman[]={\"M\",\"CM\",\"D\",\"CD\",\"C\",\"XC\",\"L\",\"XL\",\"X\",\"IX\",\"V\",\"IV\",\"I\"};\n vector<int>v={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n string s=\"\";\n for(int i=0;i<v.size();i++)\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n \n std::string ans;\n while (num) {\n auto str = std::to_string(num);\n if (str[0] != '4' and str[0] != '9') {\n if (num >= 1000) {\n ans+= \"M\";\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string roman[]={\"M\",\"CM\",\"D\",\"CD\",\"C\",\"XC\",\"L\",\"XL\",\"X\",\"IX\",\"V\",\"IV\",\"I\"};\n vector<int>l={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n string s1=\"\";\n for(int i=0;i<l.size();i++){\n while(... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string ans = \"\";\n string s = to_string(num);\n vector<char>ones = {'I','X','C','M'};\n vector<char>fives = {'V','L','D'};\n reverse(s.begin(),s.end());\n for(int i = s.size()-1; i>=0; i--){\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string l[] = {\"I\",\"IV\",\"V\",\"IX\",\"X\",\"XL\",\"L\",\"XC\",\"C\",\"CD\",\"D\",\"CM\",\"M\"};\n vector<int>arr{1,4,5,9,10,40,50,90,100,400,500,900,1000};\n string h;\n \n for(int i = 12;i>=0;i--){\n w... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\nvector<int> number={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n string symbol[] = {\"M\", \"CM\", \"D\", \"CD\", \"C\", \"XC\", \"L\",\n \"XL\", \"X\", \"IX\", \"V\", \"IV\", \"I\"};\nstring ans=\"\";\n for(... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n string intToRoman(int num) {\n string answer = \"\";\n\n while(num) {\n answer += nextRoman(num);\n }\n\n return answer;\n }\nprivate:\n string nextRoman(int &num) {\n if (num >= 1000) {\n num -= 1000;\n ... |
12 | <p>Seven different symbols represent Roman numerals with the following values:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>I</td>
<td>1</td>
</tr>
<tr>
<td>V</td>
<td>5</td>
</tr>
<tr>
<td>X</td>
<td>10</td>
</tr>
<tr>
<td>L</t... | 1 | {
"code": "class Solution {\npublic:\n void speedUp() {\n std::ios_base::sync_with_stdio(0);\n std::cin.tie(0);\n }\n\n std::string Is(int _num) {\n std::string is = \"\";\n int no_is = 0;\n if (_num % 5 > 0 &&_num % 5 <= 3) {\n no_is = _num % 5;\n }\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.