id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\nint lcs(string s1, string s2)\n{\n vector<vector<int>> dp(s1.size()+1, vector<int>(s2.size()+1, 0));\n int n = s1.size();\n int m = s2.size();\n for(int i = 1; i <= n; i++)\n {\n for(int j = 1; j <= m; j++)\n {\n \n if(s1[i-1] == s2[j-1])\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\n\n int dp[101][101][201];\n\n bool Solve(int i , int j, int k, string s1, string s2, string s3)\n {\n if(i == s1.size() && j == s2.size() && k == s3.size())\n return true;\n \n if(k >= s3.size())\n return false;\n \n if(dp[i][j][...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool help(string s, string t, string l,int i,int j,vector<vector<int>> &dp){\n \n if(i == s.size() && j == t.size() && i+j == l.size()){\n return true;\n }\n if(dp[i][j] != -1) return dp[i][j];\n\n bool pick = false;\n if(i...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool checkIsInterleave(string s1, string s2, string s3, int len1, int len2, int len3,\n int i1, int i2, int i3, map<pair<pair<int,int>,int>,bool>&m) {\n // Base cases\n if (i3 == len3) return (i1 == len1 && i2 == len2);\n bool ans1 = false, ans2 = false;\n if(m.fi...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool helper(int i, int j,int k,string s1, string s2, string s3,vector<vector<int>> &dp)\n {\n bool b = 0;\n int n = s1.size();\n int m = s2.size();\n if(k == n+m) return 1;\n if(i<n && j<m && dp[i][j] != -1)\n {\n return...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool sol(int i,int j,int k,string s1,string s2,string s3,vector<vector<int>>&dp){\n int n=s1.size();\n int m=s2.size();\n int o=s3.size();\n \n if(k==o && i==n && j==m)return true;\n if(k>o)return false;\n \n if(i<n && j...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n vector<vector<int>> memo(s1.length(), vector<int>(s2.length(), -1));\n return helper(s1, 0, s2, 0, s3, 0, \"\", memo);\n }\n\n bool helper(string s1, int s1Index, string s2, int s2Index, string s3, int...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\n unordered_map<string,bool> mem;\n bool check(string s1,string s2,string s3,int len1,int len2,int len3,int p1,int p2,int p3)\n {\n if(p3==len3) return (p1==len1 and p2==len2) ? true : false;\n string key = to_string(p1)+\"*\"+to_string(p2)+\"*\"+to_string(p3);\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n unordered_map<string,bool> mem;\n bool helper(int p1,int p2,int p3,string s1,string s2,string s3)\n {\n string key=to_string(p1)+\"*\"+to_string(p2);\n if(mem.find(key)!=mem.end())\n {\n return mem[key];\n }\n if(p1==s1.size...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": " unordered_map<string,bool> mp;\nclass Solution {\npublic:\n \n bool isValid(string s1,string s2,string s3,int n,int m, int l, int p1,int p2,int p3)\n {\n if(p3==l){\n if(p1==n && p2==m) return true;\n return false;\n }\n string key = to_string(p1)+\"*\"+t...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool check(string s1, string s2, string s3, int l1, int l2, int l3, int p1, int p2, int p3, unordered_map<string, bool> &mem)\n {\n if(p3==l3)\n {\n if(p1==l1 && p2==l2)\n return true;\n else \n return false...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3 ){\n vector<vector<int>>dp(101,vector<int>(101,-1));\n return solve(0,0,0,s1,s2,s3,dp);\n \n }\n bool solve(int i, int j, int k, string a, string b, string c,vector<vector<int>>&dp)\n {\n if(k==c....
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n void helper(string s1,string s2,string s3,string temp,int index1,int index2,int index3,bool &ans,vector<vector<bool>>&dp){\n if(index1 == s1.size() && index2 == s2.size()) {\n if(temp == s3) {\n ans = true;\n }\n return;\n }\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n if (s1.size() + s2.size() != s3.size()) { return false; }\n vector<vector<vector<bool>>> ok;\n for (int i = 0; i <= s3.size(); ++i) {\n ok.push_back(vector<vector<bool>>());\n fo...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n/* Real Test Case \n\n s1 =\n \"aabc\"\n s2 =\n \"abad\"\n s3 =\n \"aabcabad\"\n*/\n\n bool usingRec(string s1, string s2, string s3 , int i ,int j ,int k){\n if(i == s1.l...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[101][101][201];\n bool helper(string s1,string s2, string s3,int i,int j,int k){\n if(k==s3.length() && i==s1.length() && j==s2.length()){\n return true;\n }\n else if(k==s3.length()){\n return false;\n }\n el...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\nint n , m , p ;\n int dp[101][101][201];\nbool solve (string s1 , string s2 ,string s3 ,int i , int j , int k) {\n \n if (k == p && i == n && j == m )\n return true ;\n\n bool ans = 0;\n\n if (dp[i][j][k]!=-1)\n return dp[i][j][k];\n\n if...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[105][105][205];\n bool isInterleave(string s1, string s2, string s3) {\n memset(dp, -1, sizeof dp);\n return solve(s1,0,s2,0,s3,0);\n }\n\n bool solve(string s1, int i1, string s2, int i2, string s3, int i3){\n if(i1>=s1.size() && i2>=s2.s...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[101][101][201];\n bool solve(int i, int j, int k, string s1, string s2, string s3){\n if(k== s3.size() && i==s1.size() && j==s2.size())return true;\n if(s3[k] != s1[i] && s3[k] != s2[j]) return false;\n if(i >= s1.size() && s3[k] != s2[j]) retur...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n\n int dp[205][205][205];\n int isPossible(int i,int j,int k,int flag,int n1,int n2,int n3,string& s1,string& s2,string& s3){\n //cout << i << \" \" << j << \" \" << k << endl;\n if(i >= n1 && j >= n2 && k >= n3)\n return 1;\n if(k >= n3)\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n\n int dp[205][205][205];\n int isPossible(int i,int j,int k,int flag,int n1,int n2,int n3,string& s1,string& s2,string& s3){\n //cout << i << \" \" << j << \" \" << k << endl;\n if(i >= n1 && j >= n2 && k >= n3)\n return 1;\n if(k >= n3)\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n vector<vector<vector<bool>>> dp(s3.length()+1);\n if(s1.length() + s2.length() != s3.length())\n return false;\n for(int i = 0; i <= s3.length(); i++) {\n vector<vector<bool>> v;...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[101][101];\n bool solve(string s1,string s2,string s3,int i,int j,int k){\n if(k==s3.size()){\n return i==s1.size() && j==s2.size();\n }\n if(dp[i][j]!=-1) return dp[i][j]; \n int ans=0;\n if(s1[i]==s3[k] && s2[j]==s3[k]...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n constexpr bool helper(const string& s1, const int s1i, const string& s2, const int s2i, const string& s3, const int s3i, vector<vector<vector<short>>>& dp) const noexcept {\n if(s3i == s3.size()) {\n return true;\n }\n else if(dp[s1i][s2i][s3i]...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n constexpr bool helper(const string& s1, const int s1i, const string& s2, const int s2i, const string& s3, vector<vector<vector<short>>>& dp) const noexcept {\n const auto s3i = s1i + s2i;\n if(s3i == s3.size()) {\n return true;\n }\n els...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n /*\n bool isInterleave(string s1, string s2, string s3) {\n int s1Len = s1.length();\n int s2Len = s2.length();\n int s3Len = s3.length();\n\n int i = 0;\n int j = 0;\n int k = 0;\n while (i<s1Len || j<s2Len) {\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n /*\n bool isInterleave(string s1, string s2, string s3) {\n int s1Len = s1.length();\n int s2Len = s2.length();\n int s3Len = s3.length();\n\n int i = 0;\n int j = 0;\n int k = 0;\n while (i<s1Len || j<s2Len) {\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n if( s3.size() != s1.size() + s2.size() ) return false;\n return solve( s1, s2, s3, \"\", 0, 0 );\n }\n\nprivate:\n map<pair<int, int>, bool> m;\n\n bool solve( string s1, string s2, string s3, strin...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n\n unordered_map<string, bool> map;\n bool isInterleave(string s1, string s2, string s3) {\n \n string key = s1 + \"#\" + s2 + \"#\" + s3;\n\n if(map.count(key) > 0 ){\n return map[key];\n }\n\n if(s1.empty()){\n retu...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n unordered_map<string, bool> dp;\n bool isInterleave(string A, string B, string C) {\n \n if(!A.size()&&!B.size()&&!C.size())\n return true;\n if(!C.size())\n return false;\n\n string key = A+\"#\"+B+\"#\"+C;\n\n if(d...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[101][101][201];\n bool solve(int i,int j,int k,string s1,string s2,string s3)\n {\n if(i>=s1.size() and j>=s2.size() and k>=s3.size())\n return true;\n // if(i>=s1.size() and j<s2.size()||i<s1.size() and j>s2.size())return false;\n if(d...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int N= 155;\nint dp[205][205][205];\n\nbool help(int i, int j, int k ,string A, string B, string C){\n if(i<0 && j<0 && k<0) return 1;\n if(dp[i+1][j+1][k+1]!=-1) return dp[i+1][j+1][k+1];\n if(j>=0 && k>=0 && C[i]==A[j] && C[i]==B[k]){\n return dp[i+1][j+1][k...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int N= 155;\nint dp[205][205][205];\n\nbool help(int i, int j, int k ,string A, string B, string C){\n if(i<0 && j<0 && k<0) return 1;\n if(dp[i+1][j+1][k+1]!=-1) return dp[i+1][j+1][k+1];\n if(j>=0 && k>=0 && C[i]==A[j] && C[i]==B[k]){\n return dp[i+1][j+1][k...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n \n int n = s1.size();\n int m = s2.size();\n int l = s3.size();\n \n if (n + m != l) {\n return false;\n }\n \n map<vector<string >, bool >dp;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\n unordered_map<string, bool> dp = {};\npublic:\n std::string getKey(string s1, string s2, string s3, int i1, int i2, int i3){\n std::string str1 = (i1 < s1.size() ? s1.substr(i1, s1.size()-i1+1) : \" \");\n std::string str2 = (i2 < s2.size() ? s2.substr(i2, s2.size()-i2+1)...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\nint dp[101][101][202];\n int sol(int i, int j, int k,string s1, string s2, string s3 )\n {\n\n if(k==s3.size() and i==s1.size() and j==s2.size())\n return 1; \n if(i==s1.size())\n {\n if(s2[j]== s3[k])\n {\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[201][201][201];\n bool rec(int i,int j,int k,string s,string t,string w){\n if(k==w.size()){\n return true;\n }\n if(i==s.size() && j==t.size()){\n return false;\n }\n if(dp[i][j][k] != -1) return dp[i][j][k];...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool canform(string s1,string s2, string s3, vector<vector<int>> &dp, int i, int j, int n1, int n2)\n {\n if(i==n1 && j==n2)\n {\n dp[i][j]=1;\n return true;\n }\n if(s1[i]!=s3[i+j] && s2[j]!=s3[i+j])\n {\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "\n\n \n const int N = 200;\nclass Solution\n{\npublic:\n int dp[N][N][N];\n Solution()\n {\n memset(dp, -1, sizeof(dp));\n }\n bool func(int i, int j, int k, string s1, string s2, string s3)\n {\n if (k == s3.size())\n return true;\n if (i == s1.s...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[201][201][201];\n bool solve(int i,int j, int k,string s1, string s2, string s3){\n if(i==s1.size() && j==s2.size() && k==s3.size())return true;\n if(i==s1.size() && j==s2.size())return false;\n if(s1[i]!=s3[k] && s2[j]!=s3[k])return false;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[201][201][201];\n bool solve(int i,int j, int k,string s1, string s2, string s3){\n if(i==s1.size() && j==s2.size() && k==s3.size())return true;\n if(i==s1.size() && j==s2.size())return false;\n if(s1[i]!=s3[k] && s2[j]!=s3[k])return false;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool f(int i,int j,int k,int a,int b,int c,string &s1, string &s2, string &s3,vector<vector<vector<int>>>&dp){\n if( j==b && i==a) return true;\n\n if(dp[i][j][k]!=-1) return dp[i][j][k];\n\n if(i==a) \n {\n if(s2[j]!=s3[k]) return false...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\n int memo[201][201][201];\n int fn(int idx1, int idx2, int idx, string s1, string s2, string s)\n {\n if(idx == s.length())\n {\n if(idx1 == s1.length() and idx2 == s2.length())\n return true;\n return false;\n }\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[202][202][202];\n \n bool solve(int i, int j, int k, string a, string b, string c){\n if(i == a.size() and j == b.size() and k == c.size()){\n return true;\n }\n if(k >= c.size())return false;\n\n if(dp[i][j][k] != -1)return...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int checked[104][104] = {0};\n int l1, l2;\n bool process(string s1, string s2, string s3) {\n if (s1.length() + s2.length() != s3.length()) return false;\n if (s1.length() == s2.length() && s1.length() == 0) return true;\n bool check = false;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int checked[104][104] = {0};\n int l1, l2;\n bool process(string s1, string s2, string s3) {\n if (s1.length() + s2.length() != s3.length()) return false;\n if (s1.length() == s2.length() && s1.length() == 0) return true;\n bool check = false;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int checked[104][104] = {0};\n int l1, l2;\n bool process(string s1, string s2, string s3) {\n if (s1.length() + s2.length() != s3.length()) return false;\n if (s1.length() == s2.length() && s1.length() == 0) return true;\n bool check = false;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> checked;\n int l1, l2;\n bool process(string s1, string s2, string s3) {\n if (s1.length() + s2.length() != s3.length()) return false;\n if (s1.length() == s2.length() && s1.length() == 0) return true;\n bool check = false;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\n bool isInterleave(string s1,int b1,string s2,int b2,string s3,int b3,bool isFirst){\n if(!isFirst){\n std::swap(s1,s2);\n std::swap(b1,b2);\n } \n int sz1 = s1.length(),sz2 = s2.length(),sz3 = s3.length();\n if(b1 == sz1 && b2 == s...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int dp[102][102][202][2];\n int rec(int i1 , int i2 , int i3 , int ch, string s1 , string s2 , string s3){\n if(i3 == s3.length()){\n if(i1 == s1.length() && i2 == s2.length()){\n return 1;\n }\n else{\n return 0;\n }\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int summ(string &s1, string &s2, string &s3, int i, int j, int k, vector<vector<vector<int>>> &dp) {\n if (k < 0) {\n if (i < 0 && j < 0) return 1;\n return 0;\n }\n if (i >= 0 && j >= 0 && dp[i][j][k] != -1) return dp[i][j][k];\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool find(int i,int j,int k,string& s1,string& s2,string& s3,int n1,int n2,int n3,vector<vector<vector<int>>>&dp)\n {\n \n if(i==n1)\n {\n while(j<n2)\n {\n if(s2[j]!=s3[k])\n {\n r...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool find(int i,int j,int k,string& s1,string& s2,string& s3,int n1,int n2,int n3,vector<vector<vector<int>>>&dp)\n {\n \n if(i==n1)\n {\n while(j<n2)\n {\n if(s2[j]!=s3[k])\n {\n r...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool find(int i,int j,int k,string& s1,string& s2,string& s3,int n1,int n2,int n3,vector<vector<vector<int>>>&dp)\n {\n \n if(i==n1)\n {\n while(j<n2)\n {\n if(s2[j]!=s3[k])\n {\n r...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\nbool f(int i,int j,int k,string &s1,string &s2,string &s3, vector<vector<vector<int>>> &dp){\n // base case \n if (k<0){\n if (i<0&&j<0){\n return 1;\n }\n return 0;\n }\n\n if (i>=0&&j>=0&&k>=0){\n if (dp[i][j][k]!=-1){\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool fun(int i,int j,int ind,string &s1,string &s2,string &s3,vector <vector <vector <int>>> &dp){\n if(i>=s1.size() and j>=s2.size()) return ind>=s3.size();\n if(i>=s1.size()){\n int jnd=j,k=ind;\n while(jnd<s2.size() and k<s3.size()){\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\nvector<vector<vector<int>>>dp;\nbool solve(int idx1,int idx2,int idx3,string &s1,string&s2,string&s3){\n if(idx3>=s3.size())return 1;\n bool ans=0;\n if(dp[idx1][idx2][idx3]!=-1)return dp[idx1][idx2][idx3];\n if(idx1<s1.size()&&s1[idx1]==s3[idx3])ans=ans||solve(idx1+1,...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\n int solve(int i ,int j ,int k ,string& s1 , string & s2 , string& s3,vector<vector<vector<int>>>&dp){\n if(k>=s3.length()) return 0;\n if(i>= s1.length()){\n if(s2.substr(j)==s3.substr(k)) return 1;\n else return 0;\n }\n if(j>= s2.len...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool solve(const string& s1, const string& s2, const string& s3, int i, int j, int k, vector<vector<vector<int>>>& dp) {\n // Base cases\n if (k == s3.length()) {\n return i == s1.length() && j == s2.length();\n }\n if (i == s1.length() ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool c(int i1,int i2,int i3,string &s1,string &s2,string &s3,\n vector<vector<vector<int>>>&dp){\n if(i3==s3.size()){\n if(i2==s2.size() && i1==s1.size())return true;\n else return false;\n }\n char c1='*',c2='*';\n if(dp[i...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n\n bool isPossible(string& s1, string& s2, string& s3, int index1, int index2, int index3,vector<vector<vector<int>>>& dp){\n if(index1==s1.length() && index2==s2.length() && index3==s3.length()){\n return true;\n }\n if(dp[index1][index2][index...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\nbool helper(int idx1,int idx2,int idx3,string &s1,string &s2,string &s3,vector<vector<vector<int>>>&dp){\n\n if(idx3==0){\n if(idx1==0&&idx2==0) return true;\n else return false;\n } \n\n if(dp[idx1][idx2][idx3]!=-1) return dp[idx1][idx2][idx3];\n //both...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\nprivate:\n int rec(string& s1, string& s2, string& s3, int idx1, int idx2, int idx3, int n1, int n2, int n3, vector<vector<vector<int>>>& dp){\n if(dp[idx1][idx2][idx3] != -1) return dp[idx1][idx2][idx3];\n if(idx1 == n1 && idx2 == n2 && idx3 == n3) return dp[n1][n2][n3] ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\nprivate:\n int rec(string& s1, string& s2, string& s3, int idx1, int idx2, int idx3, int n1, int n2, int n3, vector<vector<vector<int>>>& dp){\n if(dp[idx1][idx2][idx3] != -1) return dp[idx1][idx2][idx3];\n if(idx1 == n1 && idx2 == n2 && idx3 == n3) return dp[n1][n2][n3] ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int f(int i,int j,int k,string &s1,string &s2,string &s3,vector<vector<vector<int>>> &dp)\n {\n if (i == s1.length() && j == s2.length() && k == s3.length()) \n {\n return 1;\n }\n if(i>s1.size() && j>s2.size()) return 0;\n if(...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int memo[105][105][200][5];\n bool solve(string s1, string s2, string s3, int idx1, int idx2, int idx3, int currStr){\n\n if(currStr ==1){\n if (idx3 >= s3.size() && idx1>=s1.size() && idx2==s2.size()-1){\n return true;\n }\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n int i1 = 0;\n int i2 = 0;\n int i3 = 0;\n\n int n3 = s3.length();\n int n2 = s2.length();\n int n1 = s1.length();\n if (n1 + n2 > n3) {\n return false;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool rec(int i,int j, int k, string s1, string s2, string s3,vector<vector<vector<int>>> &dp)\n {\n if(k<0)\n {\n return true;\n }\n if(i<0 && j<0)\n {\n return false;\n }\n \n bool ans = false...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n if(s3.length() != s1.length() + s2.length()) return false;\n if(s1==\"\" && s2==\"\" && s3==\"\") return true;\n int n1=s1.size(), n2=s2.size(), n3=s3.size();\n vector<vector<vector<int>>> map(...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n vector<vector<vector<int>>> dp;\n bool interleave(string &s1, string &s2, string &s3, int index1, int index2, int index3){\n \n if(index1 == s1.size())\n return s2.substr(index2) == s3.substr(index3);\n \n if(index2 == s2.size())\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n int n, m, k;\n vector<vector<vector<int>>> memo;\n \n bool solve(int i, int j, int l, string &s1, string &s2, string & s3){\n if(i > n || j > m || l > k){\n return false;\n }\n if(i == n && j == m && l == k){\n memo[i][j][l]...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool f(string &s1, string &s2, int i, int j, int pre, string &s3, vector<vector<vector<int>>>&dp) {\n if (i == s1.size() && j == s2.size()) return true; \n if(dp[i][j][pre+1]!=-1)return dp[i][j][pre+1];\n // pre == 1 means we take s1; pre == 0 means we t...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n int n = s1.size();\n int m = s2.size();\n int sz = s3.size();\n\n if(n + m != sz) return 0;\n\n int dp[301][301][201];\n\n memset(dp, -1, sizeof(dp));\n\n function<int(int,...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool isInterleave(string s1, string s2, string s3) {\n int n = s1.size();\n int m = s2.size();\n int sz = s3.size();\n\n if(n + m != sz) return 0;\n\n int dp[301][301][201];\n\n memset(dp, -1, sizeof(dp));\n\n function<int(int,...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool f(int i,int j,int k,string s1,string s2,string s3,vector<vector<vector<int>>>&dp){\n if(i<0 and j<0 and k<0){\n return true;\n }\n if(i<0 and j<0 and k>=0) return false;\n if(k<0 and (i>=0||j>=0)) return false; \n if(i>-1 and...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool f(string s1, int ind1, string s2, int ind2, string s3, int ind3, vector<vector<vector<int>>>& dp) {\n if (ind1 < 0 && ind2 < 0 && ind3 < 0)\n return true;\n if (ind1 >= 0 && ind2 >= 0 && ind3 >= 0 && dp[ind1][ind2][ind3] != -1)\n retur...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool rec(int i , int j , int k , string &s1 , string &s2 , string s3 ,vector<vector<vector<int>>> &dp){\n if(i == s1.size() && j == s2.size() && k ==s3.size()) return true;\n bool ans = false ;\n if(dp[i][j][k] !=-1) return dp[i][j][k];\n if(i < s1.siz...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n string s1, s2, target;\n map<vector<int>, bool> mp;\n bool dfs(int p1, int p2, int index, int sub1, int sub2, int prev){\n if(abs(sub1 - sub2) > 1) return false;\n if(index == target.length()){ \n if(p1 >= s1.length() && p2 >= s2.length()) return...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool solve(string s1,string s2,string s3,int n,int m,int k,vector<vector<vector<int>>>&dp){\n if(k<0 && n<0 && m<0)return true;\n if(n<0 && m<0)return false;\n if(dp[n+1][m+1][k+1]!=-1)return dp[n+1][m+1][k+1];\n if(n>=0 && k>=0&&s1[n]==s3[k]){\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool solveUsingRE(string& s1, string& s2, string& s3, int i, int j, int k){\n if (k == s3.size()) {\n return i == s1.size() && j == s2.size();\n }\n\n bool flag = false;\n\n if(s1[i] == s3[k] && i < s1.size())\n flag = flag ||...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool f(int i,int j,int k,string s1,string s2,string s3,vector<vector<vector<int>>>&dp){\n if(k<0){\n if(i<0 && j<0){\n return true;\n }\n return false;\n }\n int flag=0;\n if(i>=0 && j>=0){\n if(dp...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool Solve(string &s1,string &s2,string &s3,int i,int j,int k,vector<vector<vector<int>>>&dp){\n if(i==s1.size()&&j==s2.size()&&k==s3.size()){\n return true;\n }\n if(dp[i][j][k]!=-1){\n return dp[i][j][k];\n }\n bool a...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool helper(int i,int j,int k , string s1, string s2, string s3,vector<vector<vector<int>>> &dp)\n {\n // base case\n // success- all 3 at end of strings\n // fail-any other case\n if(i==s1.size() && j==s2.size() && k==s3.size()) return true;\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool solve(int i,int j,int k,int n,int m,int choice,string s1,string s2,string s3,vector<vector<vector<int>>> &dp){\n if(i==s1.size() && j==s2.size()) return k==s3.size() && abs(n-m)<=1;\n if(k==s3.size()) return i==s1.size() && j==s2.size();\n if(i==s1.s...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n\n bool solving (int n, int m, int l, string s1, string s2, string s3, vector <vector <vector <int>>> & dp) {\n if (n == -1) {\n if (m != l) {\n return 0;\n }\n while (m >= 0) {\n if (s2[m] != s3[m]) {\n ...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\n bool stringMatch(int idx1, int idx2, int k, string s1, string s2, string target, vector<vector<vector<int>>>& dp) {\n if (idx1 == s1.length() && idx2 == s2.length() && k == target.length()) return true;\n if (k == target.length()) return false;\n if (dp[idx1][idx2...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n vector<vector<vector<int>>> memo;\n bool count (int i, int j, int k, string s1, string s2, string t)\n {\n if (k == t.length()) return true; // If we've checked all characters of t\n if (i == s1.length() && j == s2.length()) return false; // If both stri...
97
<p>Given strings <code>s1</code>, <code>s2</code>, and <code>s3</code>, find whether <code>s3</code> is formed by an <strong>interleaving</strong> of <code>s1</code> and <code>s2</code>.</p> <p>An <strong>interleaving</strong> of two strings <code>s</code> and <code>t</code> is a configuration where <code>s</code> and...
3
{ "code": "class Solution {\npublic:\n bool solve(string s1,string s2,string s3,int i,int j,int k,vector<vector<vector<int>>>&dp)\n {\n if(i==s1.size() && j==s2.size() && k==s3.size())\n {\n return true;\n }\n if(k>=s3.size())\n {\n return false;\n ...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "// MORRIS\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *le...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "// MORRIS\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *le...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
98
<p>Given the <code>root</code> of a binary tree, <em>determine if it is a valid binary search tree (BST)</em>.</p> <p>A <strong>valid BST</strong> is defined as follows:</p> <ul> <li>The left <span data-keyword="subtree">subtree</span> of a node contains only nodes with keys <strong>less than</strong> the node&#39;s...
0
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...