id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n int n;\n vector<string> result;\n \n bool isValid(string str) {\n if(str[0] == '0')\n return false;\n \n int val = stoi(str);\n \n return val <= 255;\n }\n \n void solve(string& s, int idx, int part, string curr)...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\n int n;\n vector<string> result;\n\n bool isValid(string str){\n if(str[0] == '0') return false;\n int val = stoi(str);\n return val<=255;\n }\n\n void solve(string& s, int idx, int parts, string curr){\n if(idx == n && parts == 4){\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n void helper(string s,int index, string res,int count,vector<string> &ans)\n {\n if(index>= s.length())\n {\n if(count==4){\n res = res.substr(0,res.length()-1);\n ans.push_back(res);\n }\n return;...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\n void checkValidIps(vector<string> s, vector<string> & ips){\n string ip = s[0] + \".\" + s[1] + \".\" + s[2] + \".\" + s[3];\n cout << ip << endl;\n\n if (s[0].size()>3 || s[1].size()>3 || s[2].size()>3 || s[3].size()>3) return;\n for (int i = 0;...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n int n;\n vector<string>result;\n bool isValid(string str){\n if(str[0] == '0')return 0;\n int a = stoi(str);\n if(a < 0 || a > 255)return 0;\n return 1;\n }\n void solve(string s, int p, int i, string ans){\n if(i == n && p == 4)...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string>result;\n int n;\n bool valid(string s)\n {\n if(s[0]=='0')\n return false;\n int val=stoi(s);\n return val<=255;\n }\n void solve(string s,int index,int parts,string curr)\n {\n if(index==n && parts==...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n void solve(int ind, int dots, string &s, string temp, vector<string> &ans, int n){\n if(ind>=n){\n if(dots==4){\n temp.pop_back();\n ans.push_back(temp);\n }\n return;\n }\n\n if(s[ind]=='0'){...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\n vector<string> ans;\n int n;\n\n bool isValid(string vec){\n if(vec[0] == '0'){\n return false;\n }\n\n return stoi(vec) <= 255;\n }\n\n void solve(string &s, int idx, int part, string curr){\n\n if(idx == n && part == 4){\...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n void helper(string& s, int index, int cnt, vector<string>& ans) {\n if (index == s.length())\n return;\n if (cnt == 3) {\n int j = 0;\n string curr;\n bool con = true;\n while (j < s.length()) {\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\n vector<vector<string>> getIP(string s, int nums, string prefix){\n\n vector<vector<string>>output;\n\n if(prefix.size()>3 || (prefix.size()!=0 && stoi(prefix)>255)){\n return output;\n }\n if(s.size() > nums * 3){\n return output;\n }\n\n if(...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> restoreIpAddresses(string s) {\n vector<string> ans; string cur = \"\";\n auto check = [&](string s) -> bool {\n if (s.size() >= 4) return false;\n int value = 0;\n for (int i = 0; i < s.size(); i++) {\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\n vector<string> ans;\n\n void count(string& s,int currIndex,string result,int segments){\n if(currIndex == s.size()){\n if(segments == 4){\n result.pop_back();\n ans.push_back(result);\n }\n return;\n }\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> res;\n bool check(string s){\n int n=stoi(s);\n string s2=to_string(n);\n return s2==s && n<=255;\n \n }\n void myrec(int idx, int parts, string&s, string current){\n if(idx==s.length() && parts==4){\n curr...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> restoreIpAddresses(string s) {\n string temp = \"\";\n vector<string> res;\n dfs(s,res,temp,0);\n return res;\n }\n void dfs(string s, vector<string> &res, string temp,int dots){\n if(dots==4){\n if(s.size()==...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> res;\n\n bool isvalid(string s) {\n if (s.size() > 3 || s.size() == 0) return false;\n if (s.size() > 1 && s[0] == '0') return false;\n if (s.size() && stoi(s) > 255) return false;\n return true;\n }\n\n void summ(string &s,...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n void SplitStringsAtDot (string s, vector<string>& res) {\n string str = \"\";\n for(int i=0;i<s.size();i++) {\n if(s[i] == '.') {\n res.push_back(str);\n str=\"\";\n } else {\n str.push_back(s[i]...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> a;\n bool isvalid(string g){\n vector<string> wrds;\n stringstream ss(g);\n string temp;\n while(getline(ss,temp,'.'))\n {\n \n wrds.push_back(temp);\n \n }\n if(wrds.size()<4)...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n bool validate(string x){\n cout << x << endl;\n int start = 0, end;\n for(int i = 0; i < 4; i++){\n end = x.find('.',start);\n if (x.substr(start, end-start).size() == 0) return false;\n if (x[start] == '0' && x.substr(sta...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector< string >res;\n void ips(int idx,int len, string s,int ct, string adder){\n if(idx >= len){\n if( ct == 4){\n adder.pop_back();\n res.push_back( adder );\n }\n return;\n }\n string t...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n void helper(string s,vector<string>&ans, string cur, int index, int count)\n {\n if(index>s.size())\n return;\n if(count==4 && index==s.size())\n {\n ans.push_back(cur);\n return;\n }\n if(s[index]=='0')\n...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\nbool valid(string cur) {\n if (cur.size() == 0)return true;\n int index = cur.find(\".\");\n if (index == -1) {\n if (cur.size() > 3) return false;\n if(cur[0] == '0' && cur.size() > 1) return false;\n if (stoi(cur) >= 0 && stoi(cur) <= 255) return true;\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\n void solver(string& s, int it, int n, int cntr, string cur, vector<string>& res)\n {\n if(it == n && cntr == 4)\n {\n if(cur.back() == '.') cur.pop_back();\n\n res.push_back(cur);\n return;\n }\n\n if(s[it] == ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> ans;\n bool isValid(string str){\n if(str.size() == 0 || str.size()>3){\n return false;\n }\n if(str.size()>1 && str[0] == '0'){\n return false;\n }\n if(str.size()>0 && stoi(str)>255){\n re...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\nbool valid(string cur) {\n if (cur.size() == 0)return true; //roca ukve yvela shemowmebulia da agaraferi darcha\n int index = cur.find(\".\"); //vipovot wertilis index\n\n if (index == -1) { //tu agar aris meti wertilebi, anu bolo, meotxe nawili\n if (cur.size() > 3) re...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n \n vector<string> ans;\n void sol(string s, int i, int j, string temp, int level){\n if(i == j+1 && level == 5){\n ans.push_back(temp);\n }\n \n \n for(int k =i;k<i+3 && k<=j; k++){\n \n string st = s.s...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> restoreIpAddresses(string s) {\n vector<vector<vector<vector<string>>>>mem(s.size(),vector<vector<vector<string>>>(s.size(),vector<vector<string>>(4,vector<string>())));\n vector<vector<vector<bool>>>visit(s.size(),vector<vector<bool>>(s.size(),ve...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n bool validate(string x){\n cout << x << endl;\n int start = 0, end;\n for(int i = 0; i < 4; i++){\n end = x.find('.',start);\n if (x[start] == '0' && x.substr(start, end-start).size() != 1) return false;\n if (stoll(x.subs...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\n void f (vector<string>&ans,int i, string temp, int dots, string s){\n if(dots==4 && i==s.size()){\n ans.push_back(temp.substr(1));\n return;\n }\n for(int j=i; j<i+3 && j<s.size(); j++){\n string d = s.substr(i,j-i+1);\n...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> ans;\n void helper(string s,string ip, int i) {\n if(i == s.size()) {\n if(ip.size() == s.size() + 4) {\n ans.push_back(ip.substr(0, ip.size()-1));\n }\n return;\n }\n int num = 0;\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n bool validIpAddress(string a){\n int x= stoi(a);\n if(x>0&&x<=255){\n if(a[0]!='0'){\n return true;\n }\n return false;\n }\n if(x==0&&a.length()==1){ \n return true;\n }\n return false;\n }\n vector<string> restore...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n void helper(vector<string>& res, string s, string curr, int dot, int index){\n if(dot == 4 && index == s.length() ){\n curr = curr.substr(0, curr.length() - 1);\n res.push_back(curr);\n return;\n }\n for(int i = index; i <...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string>ans;\n void dfs(int i,string s,string temp,int cnt)\n {\n if(i>=s.length() && cnt==4)\n {\n string mn=temp;\n mn.pop_back();\n ans.push_back(mn);\n return;\n }\n string str;\n\n for...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n bool valid(const string& s, int start, int length) {\n\n //cout<< s.substr(start, length)<<endl;\n\n return length == 1 ||\n (s[start] != '0' &&\n (length < 3 || length <= 3 && s.substr(start, length) <= \"255\"));\n }\n vecto...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> restoreIpAddresses(string s) {\n vector<string> res;\n helper(s, 0, \"\", 0, res);\n return res;\n }\n void helper(string& s, int start, string sol, int idx, vector<string>& res){\n if(start == s.size()){\n if(idx ==...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> finalAns;\n string curr = \"\";\n\n vector<string> split(string s){\n vector<string> result;\n stringstream ss (s);\n string item;\n\n while(getline(ss, item, '.')){\n result.push_back(item);\n }\n\n re...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n void solve(int index , string &s , string &path , vector<string>&ans, int cnt)\n {\n int n = s.size();\n if(index == n && cnt == 4)\n {\n path.pop_back();\n ans.push_back(path);\n return;\n }\n if(index==n...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n bool verify(string aux){\n \n int len = aux.length();\n\n int num = stoi(aux);\n\n if(len > 3 || num > 255 || (len == 3 && num < 100) || (len == 2 && num < 10)){\n return false;\n }\n\n return true;\n }\n\n bool check...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> v;\n int n;\n bool isvalid(const string &s){\n int x=0;\n int dc=0;\n for(auto i:s){\n if(i=='.'){\n dc++;\n if(dc>3) return false;\n x=0;\n }\n else if(x==...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\n vector<string> get_vars(string s){\n\n if(s == \"\") return {\"\"};\n int i = 0;\n vector<string> L;\n string t = \"\";\n while(i < 3){\n\n t += s[i];\n int x = stoi(t);\n if(x <= 255 && x >= 0 && (t[0] != ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string>v;\n bool check(string s){\n if(s.length()>1 && s[0]=='0')\n return false;\n if(s.empty())\n return false;\n int val=stoi(s);\n return val>=0 && val<=255;\n }\n void func(int ind, int n, string s, string curr){\...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\nvector<string> result;\n int isValid(string str) {\n int n = str.size();\n if (n < 7 || n > 15) return false; // Quick check based on size constraints\n \n // Split the string by '.'\n vector<string> parts;\n stringstream ss(str);\n...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string>v;\n bool check(string s){\n if(s.length()>1 && s[0]=='0')\n return false;\n if(s.empty())\n return false;\n int val=stoi(s);\n return val>=0 && val<=255;\n }\n void func(int ind, int n, string s, string curr){\...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string>v;\n bool check(string s){\n if(s.length()>1 && s[0]=='0')\n return false;\n if(s.empty())\n return false;\n int val=stoi(s);\n return val>=0 && val<=255;\n }\n void func(int ind, int n, string s, string curr){\...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\nprivate:\n vector<string> result;\n string path = \"\";\n int iDotCount = 0;\n void backtracking(string s, int startIndex){\n if(iDotCount==4 && startIndex==s.size()){\n path = path.substr(1,path.size()-1);\n result.push_back(path);\n re...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\nprivate:\n vector<string> result;\n string path = \"\";\n int iDotCount = 0;\n void backtracking(string s, int startIndex){\n if(iDotCount==4 && startIndex==s.size()){\n path = path.substr(1,path.size()-1);\n result.push_back(path);\n re...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n bool fn(int s,int e,string st){\n string str=st.substr(s,e-s+1);\n if(str.length()>3){\n return false;\n }\n\n if(str.length()>1 && str[0]=='0'){\n return false;\n }\n\n int val=stoi(str);\n if(val>=0 && v...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> restoreIpAddresses(string s) {\n vector<string> ans;\n helper(ans, \"\", s, 0,0);\n return ans;\n }\n\n void helper(vector<string> &ans, string curr, string s, int idx, int dots) {\n if (dots == 4 && idx == s.length()) {\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> restoreIpAddresses(string s) {\n return solve(s,3);\n }\n vector<string> solve(string s, int num_dot){\n set<string> res;\n if(num_dot==0){\n if(s.size()<=3&&stoi(s)>=0&&stoi(s)<=255){\n if(s.size()==1||(s.si...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string>finalans ;\n string curr ;\n\n vector<string>split(string s, char ch){\n string curr = \"\";\n vector<string>ans ;\n for(int i =0 ; i<s.size(); i++){\n if(s[i] != ch){\n curr += s[i];\n }\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\nbool isValidNum(string s){\n int val = std::atoi(s.c_str());\n return val>=0 && val <=255;\n}\nvoid resIPRec(string s, string ip, int index, int dCount, vector<string> & res){\n if (index == s.size() && dCount == 4){\n res.push_back(ip);\n return;\n }\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n bool isValid(string s){\n int num1,num2,num3,num4, n = s.length();\n char d1,d2,d3;\n stringstream ss(s);\n string str;\n // check for leading zeroes\n for(int i=0; i<n; i++){\n if(s[i]=='.'){\n if(str==\"\")...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n\n vector<vector<string>> getIP(string s, int nums, string prefix){\n\n vector<vector<string>>output;\n\n // if(prefix.size())\n if(s.size() > nums * 3){\n return output;\n }\n\n if(s.size() < nums){\n return output;\n }\n\n if(nums == 1 && p...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> finalAns;\n string curr = \"\";\n\n vector<string> split(string s){\n vector<string> result;\n stringstream ss (s);\n string item;\n\n while(getline(ss, item, '.')){\n result.push_back(item);\n }\n\n re...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n \n \n void solve(int index , int n , string s , vector<string>& ans , int num , string output) {\n if(index >= n) {\n if(num == 5){\n output.pop_back();\n ans.push_back(output);\n }\n \n re...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> restoreIpAddresses(string s) {\n vector<vector<string>> r;\n vector<string> current;\n backtrack(s, 0, current, r);\n vector<string> result;\n for(int i=0; i<r.size(); i++){\n if(r[i].size()==4){\n st...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n string curr;\n vector<string> ans;\n string st;\n vector<string> split(string s, char ch){\n vector<string> splitted;\n string turn;\n stringstream ss (s);\n while(getline(ss, turn, ch)){\n splitted.push_back(turn);\n }\n...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n string curr;\n vector<string> ans;\n string st;\n vector<string> split(string s, char ch){\n vector<string> splitted;\n string turn;\n stringstream ss (s);\n while(getline(ss, turn, ch)){\n splitted.push_back(turn);\n }\n...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "class Solution {\npublic:\n vector<string> ans;\n string curr;\n vector<string> split(string s, char ch) {\n vector<string> ans;\n stringstream ss(s);\n string item;\n while (getline(ss, item, '.')) {\n ans.push_back(item);\n }\n return ans;\n ...
93
<p>A <strong>valid IP address</strong> consists of exactly four integers separated by single dots. Each integer is between <code>0</code> and <code>255</code> (<strong>inclusive</strong>) and cannot have leading zeros.</p> <ul> <li>For example, <code>&quot;0.1.2.201&quot;</code> and <code>&quot;192.168.1.1&quot;</cod...
3
{ "code": "void helper(vector<string>& ans, int index, string s, string temp, int remain) {\n if (remain == 4 && index == s.length()) {\n ans.push_back(temp.erase(0,1));\n return;\n }\n if (index > s.size() - 1) {\n return;\n }\n temp = temp + \".\";\n if (s[index] == '0') {\n ...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
0
{ "code": "class Solution {\npublic:\n vector<int> inorderTraversal(TreeNode* root) {\n vector<int>ans;\n TreeNode* curr = root;\n while(curr!=NULL)\n {\n if(curr->left == NULL)\n {\n ans.push_back(curr->val);\n curr = curr->right;\n ...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
1
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
1
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
2
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
2
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "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...
94
<p>Given the <code>root</code> of a binary tree, return <em>the inorder traversal of its nodes&#39; values</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <span class="example-io">root = [1,null,2,3]</span></p> <p><strong>Output:</stro...
3
{ "code": "class Solution {\npublic:\n vector<int> inorderTraversal(TreeNode* root) {\n vector<int> ans;\n if (root == NULL) return ans;\n vector<int> left = inorderTraversal(root->left);\n ans.insert(ans.end(), left.begin(), left.end());\n ans.push_back(root->val);\n vector<int> right = inorderT...
95
<p>Given an integer <code>n</code>, return <em>all the structurally unique <strong>BST&#39;</strong>s (binary search trees), which has exactly </em><code>n</code><em> nodes of unique values from</em> <code>1</code> <em>to</em> <code>n</code>. Return the answer in <strong>any order</strong>.</p> <p>&nbsp;</p> <p><stron...
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...
95
<p>Given an integer <code>n</code>, return <em>all the structurally unique <strong>BST&#39;</strong>s (binary search trees), which has exactly </em><code>n</code><em> nodes of unique values from</em> <code>1</code> <em>to</em> <code>n</code>. Return the answer in <strong>any order</strong>.</p> <p>&nbsp;</p> <p><stron...
0
{ "code": "class Solution {\npublic:\n static vector<TreeNode*> generateTrees(const int node_count) {\n vector<vector<vector<TreeNode*>>> table(\n node_count + 1,\n vector<vector<TreeNode*>>(node_count + 1)\n );\n for (int i = 1; i <= node_count; ++i) {\n table[i][i].push_back(new TreeNode(i)...
95
<p>Given an integer <code>n</code>, return <em>all the structurally unique <strong>BST&#39;</strong>s (binary search trees), which has exactly </em><code>n</code><em> nodes of unique values from</em> <code>1</code> <em>to</em> <code>n</code>. Return the answer in <strong>any order</strong>.</p> <p>&nbsp;</p> <p><stron...
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...
95
<p>Given an integer <code>n</code>, return <em>all the structurally unique <strong>BST&#39;</strong>s (binary search trees), which has exactly </em><code>n</code><em> nodes of unique values from</em> <code>1</code> <em>to</em> <code>n</code>. Return the answer in <strong>any order</strong>.</p> <p>&nbsp;</p> <p><stron...
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...
95
<p>Given an integer <code>n</code>, return <em>all the structurally unique <strong>BST&#39;</strong>s (binary search trees), which has exactly </em><code>n</code><em> nodes of unique values from</em> <code>1</code> <em>to</em> <code>n</code>. Return the answer in <strong>any order</strong>.</p> <p>&nbsp;</p> <p><stron...
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...
95
<p>Given an integer <code>n</code>, return <em>all the structurally unique <strong>BST&#39;</strong>s (binary search trees), which has exactly </em><code>n</code><em> nodes of unique values from</em> <code>1</code> <em>to</em> <code>n</code>. Return the answer in <strong>any order</strong>.</p> <p>&nbsp;</p> <p><stron...
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...