id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int func(int ind, vector<string> arr, unordered_map<char, int>& mp) {\n if (ind == arr.size()) {\n return 0;\n }\n\n string s = arr[ind];\n\n set<char>st;\n bool flag = false;\n for (int i = 0; i < s.length(); i++) {\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int func(int ind, vector<string> arr, unordered_map<char, int>& mp) {\n if (ind == arr.size()) {\n return 0;\n }\n\n string s = arr[ind];\n\n set<char>st;\n bool flag = false;\n for (int i = 0; i < s.length(); i++) {\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "// class Solution {\n// public:\n\n// bool hasDuplicate(string &s1,string &s2)\n// {\n// vector<int> count(26, 0);\n// for (char c : s1) {\n// count[c - 'a']++;\n// if (count[c - 'a'] > 1) {\n// return false;\n// }\n// }\n/... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int maxlength=INT_MIN;\n int maxLength(vector<string>& arr) {\n string word;\n check(arr, 0, word);\n return maxlength;\n }\n\n void check(vector<string>arr, int i, string word){\n cout<<word<<endl;\n vector<int>v(26, 0);\n i... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int maxlength=INT_MIN;\n int maxLength(vector<string>& arr) {\n string word;\n check(arr, 0, word);\n return maxlength;\n }\n\n void check(vector<string>arr, int i, string word){\n vector<int>v(26, 0);\n int n=word.size(),n1=arr.siz... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution \n{\nprivate:\n int ans = 0;\n\n void bck(int idx, vector<string>& arr, unordered_set<char> s = {})\n {\n if(idx == arr.size())\n {\n if(s.size() > ans)\n {\n ans = s.size();\n }\n return;\n }\n\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\n void maxLengthHelper(int idx, vector<string>& arr, string temp, unordered_set<char> st, string& result){\n if(idx == arr.size()){\n if(temp.length() > result.length()){\n result = temp;\n }\n return;\n }\n\n maxLengt... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "\nint maxLen(vector<string>& arr, unordered_set<char> exclusionChars) {\n // return max len, where the given unordered_set of chars cannot be used\n\n // base case\n if (arr.size() == 0) {\n return 0;\n }\n\n // consider what to do with arr[0], then recurse on remainder of problem\n\n... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int solve(vector<string>arr,int i,vector<vector<int>>&dp,string ans){\n if(i>=arr.size())return 0;\n \n string temp=ans;\n temp+=arr[i];\n unordered_map<int,int>mp;\n for(auto i:temp){\n mp[i]++;\n }\n int f=1... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\tint solve(int index, vector<string> ans, vector<string>& arr) {\n\t\tif (index >= arr.size()) {\n\t\t\treturn 0;\n\t\t}\n\t\tans.push_back(arr[index]);\n\t\tunordered_map<char, int> freq;\n\t\tfor (int i = 0; i < ans.size(); i++) {\n\t\t\tfor (int j = 0; j < ans[i].size(); j++)... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "// https://www.youtube.com/watch?v=d4SPuvkaeoo&ab_channel=NeetCode\n\nclass Solution {\npublic: \n int maxLen = 0;\n \n bool overlap(set<char> charset, string s){\n for(char c : s){\n if(charset.find(c) != charset.end())\n return true;\n charset.inser... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "// https://www.youtube.com/watch?v=d4SPuvkaeoo&ab_channel=NeetCode\n\nclass Solution {\npublic: \n int maxLen = 0;\n \n bool overlap(set<char> charset, string s){\n for(char c : s){\n if(charset.find(c) != charset.end())\n return true;\n charset.inser... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\nbool isvalid(string str)\n{\n unordered_set<char> ust(str.begin(), str.end());\n if(ust.size() == str.size())\n {\n return true;\n }\n return false;\n}\n\nint solve(int idx, string temp, vector<string> arr)\n{\n if(idx==arr.size())return 0;\n int notpi... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n bool hasDuplicate(string &str,string &temp)\n {\n unordered_map<int,int> mp1;\n for(auto st:str)\n {\n if(mp1[st-'a']>=1)\n return true;\n mp1[st-'a']++;\n }\n for(auto ch:temp)\n {\n if(... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n bool hasDuplicate(string s1, string s2) {\n unordered_map<char, int> mpp;\n\n for(char ch: s1) {\n if(mpp.find(ch)!=mpp.end()) return true;\n mpp[ch]++;\n }\n\n for(char ch: s2) {\n if(mpp.find(ch)!=mpp.end()) ret... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\nbool check(string a,string b){\n unordered_map<char,int>m;\n for(auto i:a){\n if(m.find(i)!=m.end()){\n return false;\n }\n m[i]++;\n }\n for(auto i:b){\n if(m.find(i)!=m.end()){\n return false;\n }\n m[i]++;\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\nprivate:\n int rec(vector<string> arr,int index,vector<int> checker,int len){\n if(index == arr.size()){\n return len;\n }\n cout<<index<<endl;\n vector<int> temp = checker;\n for(char i:arr[index]){\n if(temp[i-'a'] != 0){\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n bool checkValidity(string s, string result){\n \n set<char> st;\n \n for(int i=0; i<result.length(); i++){\n \n if(st.find(result[i])!=st.end()){\n return false;\n }\n \n st.in... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int maxLength(vector<string>& arr, int currIndex,\n unordered_map<int, bool> mapping) {\n int n = arr.size();\n\n if (currIndex == n) {\n return 0;\n }\n\n string currString = arr[currIndex];\n\n bool duplicateFou... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n bool hasDuplicate(string &str,string &temp)\n {\n unordered_map<int,int> mp1;\n for(auto st:str)\n {\n if(mp1[st-'a']>=1)\n return true;\n mp1[st-'a']++;\n }\n for(auto ch:temp)\n {\n if(... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n bool hasDuplicate(string s1, string s2) {\n unordered_map<char, int> mpp;\n\n for(char ch: s1) {\n if(mpp.find(ch)!=mpp.end()) return true;\n mpp[ch]++;\n }\n\n for(char ch: s2) {\n if(mpp.find(ch)!=mpp.end()) ret... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int maxLength(vector<string>& arr) {\n int n = arr.size();\n vector<bool>vis(26,0);\n int res = 0;\n for (int num = 0 ; num <= (1 << n) ; num++){\n string str = \"\";\n for (int j = 0 ; j < n ; j++){\n if ((num&... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n bool uniqueChar(string& str){\n int store=0;\n for(int i=0;i<str.size();i++){\n int idxBit= str[i]-'a';\n if((store & (1<<idxBit))>0){\n return false;\n }\n store= store | (1<<idxBit);\n }\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n bool uniqueChar(string& str){\n int store=0;\n for(int i=0;i<str.size();i++){\n int idxBit= str[i]-'a';\n if((store & (1<<idxBit))>0){\n return false;\n }\n store= store | (1<<idxBit);\n }\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n bool unique(string s){\n set<char>st;\n for(int i=0;i<s.size();i++){\n st.insert(s[i]);\n }\n if(st.size()==s.size())return true;\n return false;\n }\n void dfs(vector<string>&arr,string temp,int curr,int &maxi){\n if(!unique(temp))return ;\n if(cu... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int maxi = 0;\n\n bool isUnique(string s){\n\n set<char> st;\n \n for(auto x : s){\n st.insert(x);\n }\n\n if(s.size() == st.size()){\n return true;\n }\n \n return false;\n }\n\n void solv... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n int maxi = 0;\n\n bool isUnique(string s){\n\n set<char> st;\n \n for(auto x : s){\n st.insert(x);\n }\n\n if(s.size() == st.size()){\n return true;\n }\n \n return false;\n }\n\n void so... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\nprivate:\n bool have_unique_char(string& str){\n int store = 0;\n for(int i = 0; i < str.size(); i++){\n int idx_bit = str[i] - 'a';\n\n if((store & (1 << idx_bit)) > 0){\n return false;\n }\n store = store | (1 <... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int ans =0;\n bool uniqueChar(string& str){\n int store =0;\n for(int i =0 ;i < str.size();i++){\n int indexBit =str[i] - 'a';\n if((store & (1 << indexBit))>0){\n return false;\n }\n store = store | ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\nint dfs(int i,string prev,vector<string> arr)\n {\n if(i>=arr.size())return 0;\n string last=prev+arr[i];\n set<char>st;\n int take=0;\n for(auto x:last)st.insert(x);\n if(st.size()!=last.size())\n {\n return dfs(i+1,prev,... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n vector<unordered_set<char>> st;\n int f(int idx,vector<string> &arr,unordered_set<char> &temp){\n int n = arr.size();\n if(idx>=n) return 0;\n int ans = 0;\n for(int j=idx;j<n;j++){\n if(arr[j].size()!=st[j].size()) continue;\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n bool checkValidity(string s, string result){\n \n set<char> st;\n \n for(int i=0; i<result.length(); i++){\n \n if(st.find(result[i])!=st.end()){\n return false;\n }\n \n st.in... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n std::pair<bool, int> check(std::vector<std::string>& arr, int mask) {\n bool is_valid = true;\n int length = 0;\n std::vector<int> counter(26, 0);\n for(int j = 0; j < arr.size(); ++j) {\n int test_bit = 1 << j;\n if (test_b... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n int helper(int i,vector<string> &arr,unordered_set<char> st){\n if(i < 0) return st.size();\n\n int res = helper(i-1,arr,st);\n unordered_set<char> st1 = st;\n for(auto &it:arr[i]){\n if(st1.find(it) != st1.end()) return res;\n ... |
1,360 | <p>You are given an array of strings <code>arr</code>. A string <code>s</code> is formed by the <strong>concatenation</strong> of a <strong>subsequence</strong> of <code>arr</code> that has <strong>unique characters</strong>.</p>
<p>Return <em>the <strong>maximum</strong> possible length</em> of <code>s</code>.</p>
<... | 3 | {
"code": "class Solution {\npublic:\n\n bool isUnique(string s){\n unordered_set<char> set;\n for(char c:s){\n if(set.count(c)){\n return false;\n }\n set.insert(c);\n }\n return true;\n }\n\n int helper(vector<string> up, string p ... |
3,056 | <p>You are given four integers <code>sx</code>, <code>sy</code>, <code>fx</code>, <code>fy</code>, and a <strong>non-negative</strong> integer <code>t</code>.</p>
<p>In an infinite 2D grid, you start at the cell <code>(sx, sy)</code>. Each second, you <strong>must</strong> move to any of its adjacent cells.</p>
<p>Re... | 0 | {
"code": "class Solution {\npublic:\n bool isReachableAtTime(int sx, int sy, int fx, int fy, int t) {\n if(sx==fx && sy==fy){\n if(t==1) return false;\n return true;\n }\n int x=abs(sx-fx);\n int y=abs(sy-fy);\n\n if(max(x,y)>t) return false;\n retur... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\n bool isv(char &c){\n if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){\n return 1;\n }\n return 0;\n }\npublic:\n int maxVowels(string &s, int k) {\n int x=0,m=0;\n for(int i=0;i<k;i++){\n if(isv(s[i]))x++;\n }\n m... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n bool isVowel(const char& c){\n if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') return true;\n return false;\n }\n int maxVowels(const string_view &s, int k) {\n int count{0},max{0};\n for(int i=0;i<s.size();++i){\n if(isVowel(s[i]))++co... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n inline static int maxVowels(const string& s, int k) {\n int vowels = 0;\n int cnt = 0;\n\n vowels |= 1 << ('a' - 'a');\n vowels |= 1 << ('e' - 'a');\n vowels |= 1 << ('i' - 'a');\n vowels |= 1 << ('o' - 'a');\n vowels |= 1 << (... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n inline static int maxVowels(const string& s, int k) {\n int vowels = 0;\n int cnt = 0;\n int i = 0;\n\n vowels |= 1 << ('a' - 'a');\n vowels |= 1 << ('e' - 'a');\n vowels |= 1 << ('i' - 'a');\n vowels |= 1 << ('o' - 'a');\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "//1456\nclass Solution {\npublic:\n bool check(char c){\n return c == 'a' || c == 'e' || c == 'i' || c == 'o'|| c == 'u';\n }\n\n int maxVowels(string_view s, int k) {\n int num{0}, Max{0};\n for(auto i{0}; i<k; ++i){\n if(check(s[i])) ++num;\n }\n \n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "//1456\nclass Solution {\npublic:\n bool check(char c){\n return c == 'a' || c == 'e' || c == 'i' || c == 'o'|| c == 'u';\n }\n\n int maxVowels(string_view s, int k) {\n int num{0}, Max{0};\n for(auto i{0}; i<k; ++i){\n if(check(s[i])) ++num;\n }\n \n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n bool isVowel(const char& c){\n if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') return true;\n return false;\n }\n int maxVowels(const string_view &s, int k) {\n int count{0},max{0};\n vector<bool> bits(s.size(),0);\n for(int i=0;i<s.size();... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n bool isVowel(const char& c){\n if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') return true;\n return false;\n }\n int maxVowels(const string_view &s, int k) {\n int count{0},max{0};\n vector<bool> bits(s.size(),0);\n for(int i=0;i<s.size();... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\nprivate:\n int is_vowel(char c) {\n return 1 ? c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' : 0;\n }\n int count_vowels(const string& s) {\n int count = 0;\n for (char c : s) {\n if (is_vowel(c) == 1) count++;\n }\n return count;\n }... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n bool isVowel(char ch) {\n if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')\n return true;\n return false;\n }\n int maxVowels(string s, int k) {\n // window size is given = k;\n int i = 0;\n int j = k - 1;\... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n bool isVowel(char c) {\n return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';\n }\n int maxVowels(string s, int k) {\n int n = s.size(), res{0}, cnt{0};\n for (int i = 0; i < k; i++)\n if (isVowel(s[i]))\n cnt++... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n int tmp{0}, rtn{0};\n\n for(int j{0}; j<k; j++){\n if(s[j] == 'a' || s[j] == 'e' || s[j] == 'i' || s[j] == 'o' || s[j] == 'u')\n tmp++;\n }\n rtn = tmp;\n for(int j{k}; j<s.siz... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n bool is_vowel(char c) {\n return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';\n }\n\n int maxVowels(string s, int k) {\n int i = 0;\n int n = s.size();\n int v = 0;\n\n // build initial window\n for (int j = 0; j < ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n int maxVowelCount = 0;\n int vowelCount = 0;\n \n // Using a boolean array for vowel checking\n bool isVowel[256] = { false };\n isVowel['a'] = isVowel['e'] = isVowel['i'] = isVowel['o'] = isVowel['u... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n string vowels=\"aeiou\";\n \n int count=0;\n for(int i=0;i<k;i++)\n {\n if(vowels.find(s[i])!=string::npos)\n {\n count++;\n }\n }\n int maxv=co... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 0 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n int i = 0, j = 0, n = s.size(), mxCount = 0, count = 0;\n unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u'};\n\n while (j < n) {\n if (vowels.find(s[j]) != vowels.end()) {\n count++;\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 1 | {
"code": "class Solution {\npublic:\n bool isVowel(char c)\n {\n return c=='a'||c=='e'|| c=='i'|| c=='o'||c=='u';\n }\n int maxVowels(string s, int k) {\n int i=0;\n int size = s.size();\n int j=k-1;\n int cnt = 0;\n for(int m=i;m<=j;m++)\n {\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 1 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n int i=0, j=0;\n int maxCount = 0, count = 0;\n \n while (j < s.size()) {\n // cout << \"s[i]: \" << s[i] << \" :: \" << \"s[j]: \" << s[j] << endl;\n // cout << \"maxCOUnt: \" << maxCount << \"... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 2 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n\tint maxVowelCount= 0;\n\tunordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u'};\n\tfor (int i=0; i<k; i++) {\n\t\tif (vowels.find(s[i])!=vowels.end()) maxVowelCount++;\n\t}\n int vowelCount = maxVowelCount;\n\tfor (int i=k; i<s.size... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 2 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n int maxVowelCount = 0;\n int vowelCount = 0;\n \n // Using a boolean array for vowel checking\n bool isVowel[256] = { false };\n isVowel['a'] = isVowel['e'] = isVowel['i'] = isVowel['o'] = isVowel['u... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n unordered_set<char>vowel = {'a','e','i','o','u'};\n\n int n = s.length();\n int cnt = 0;\n int vcnt = 0;\n for( int i = 0 ; i < k ; i++ )\n {\n if( vowel.find(s[i]) != vowel.end())\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n unordered_set<char> vowels = {'a','e','i','o','u'};\n int l=0, r=0;\n int cnt = 0;\n int maxCnt = INT_MIN;\n\n while(r < s.size()){\n if(vowels.count(s[r])){\n cnt++;\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n // helper function\n bool isVowel(char letter) {\n switch (letter) {\n case 'a':\n case 'e':\n case 'i':\n case 'o':\n case 'u':\n return true;\n default:\n return false;\n }\n }\n\n int ma... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n int n = s.size();\n\n unordered_set<char> st;\n st.insert('a');\n st.insert('e');\n st.insert('i');\n st.insert('o');\n st.insert('u');\n\n queue<char> q;\n\n int findMax = INT_M... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\nbool solve(char s){\n if(s=='a' || s=='e' || s=='i' || s=='o' || s=='u')\n return true; \n return false; \n}\n int maxVowels(string s, int k) {\n int n = s.size(); \n queue<char>q; \n int ans =INT_MIN; \n int cnt=0; \n for(int i=0;i<... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\n bool isVowel(char c) {\n return c == 'a' || c == 'e' ||\n c == 'i' || c == 'o' ||\n c == 'u';\n }\npublic:\n int maxVowels(string s, int k) { \n int maxCnt = 0;\n int curCnt = 0;\n queue<char> q;\n\n for (int ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n queue<char>q;\n int cnt=0;\n int maxi=0;\n for(int i=0;i<s.length();i++){\n if(q.size()<k){\n if(s[i]=='a' || s[i]=='e' || s[i]=='o' || s[i]=='u' || s[i]=='i'){\n cnt++... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n\n bool isVowel(char c){\n return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';\n }\n\n int maxVowels(string s, int k) {\n int n = s.size();\n\n map<char,int> mp;\n int ans=0;\n for(int i=0;i<k;i++){\n if(isVowel(s[i])){\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n bool check(char ch){\n if(ch == 'a'|| ch == 'e'|| ch == 'i' || ch == 'o' || ch == 'u'){\n return true;\n }\n return false;\n }\n int checkMax(unordered_map<char,int>&mp){\n int sum = 0;\n for(auto &it : mp){\n sum... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n map<char,int>mp;\n mp['a']=0,mp['e']=0,mp['i']=0,mp['o']=0,mp['u']=0;\n for(int i=0;i<k;i++){\n if(mp.find(s[i])!=mp.end()){\n mp[s[i]]++;\n }\n }\n int ans=0;\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n\n unordered_map<char, bool> map = {{'a', true}, {'e', true}, {'i', true}, {'o', true}, {'u', true}};\n int maxVowels = 0;\n int currVowels = 0;\n for(int i = 0; i < k; i++){\n if(map[s[i]]){\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\n //to check the char is vowel or not\n bool isvowel(char c){\n return (c=='a' || c=='e' || c=='i' || c=='o' || c=='u');\n }\n\npublic:\n int maxVowels(string s, int k) {\n int ans=0;\n int maxi=INT_MIN;\n queue<char>q;\n\n //we get our first ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n bool check(char ch){\n if(ch == 'a'|| ch == 'e'|| ch == 'i' || ch == 'o' || ch == 'u'){\n return true;\n }\n return false;\n }\n int checkMax(unordered_map<char,int>&mp){\n int sum = 0;\n for(auto &it : mp){\n sum... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n\n unordered_map<char, bool> map = {{'a', true}, {'e', true}, {'i', true}, {'o', true}, {'u', true}};\n int maxVowels = 0;\n int currVowels = 0;\n for(int i = 0; i < k; i++){\n if(map[s[i]]){\n ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\n //to check the char is vowel or not\n bool isvowel(char c){\n return (c=='a' || c=='e' || c=='i' || c=='o' || c=='u');\n }\n\npublic:\n int maxVowels(string s, int k) {\n int ans=0;\n int maxi=INT_MIN;\n queue<char>q;\n\n //we get our first ... |
1,567 | <p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the maximum number of vowel letters in any substring of </em><code>s</code><em> with length </em><code>k</code>.</p>
<p><strong>Vowel letters</strong> in English are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, ... | 3 | {
"code": "class Solution {\npublic:\n int maxVowels(string s, int k) {\n int res=0;\n map<char,int> mp;\n for(int i=0;i<k;i++){\n if(s[i]=='a' or s[i]=='e' or s[i]=='i' or s[i]=='o' or s[i]=='u'){\n mp[s[i]]++;\n }\n }\n res=max(res,mp['a']+m... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "class Solution {\nprivate:\n bool isPseudoPalindromic(const unordered_map<int, int>& freq) {\n int oddCount = 0;\n for (const auto& it : freq) {\n if (it.second % 2 == 1) {\n oddCount++;\n if (oddCount > 1) {\n return false;\n ... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "#pragma GCC target(\"avx, mmx, sse2, sse3, sse4\")\n\nauto disableSync = [](void) noexcept -> int\n{\n std::ios::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return 0;\n}();\n\ntypedef struct TreeNode NodeBT_t;\n\nclass Solution final\n{\nprivate:\n int nbVali... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "#pragma GCC target(\"avx, mmx, sse2, sse3, sse4\")\n\nauto disableSync = [](void) noexcept -> int\n{\n std::ios::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return 0;\n}();\n\ntypedef struct TreeNode NodeBT_t;\n\nclass Solution final\n{\nprivate:\n int nbVali... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "#pragma GCC target(\"avx, mmx, sse2, sse3, sse4\")\n\nauto disableSync = [](void) noexcept -> int\n{\n std::ios::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return 0;\n}();\n\ntypedef struct TreeNode NodeBT_t;\n\nclass Solution final\n{\nprivate:\n int nbVali... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "#pragma GCC target(\"avx, mmx, sse2, sse3, sse4\")\n\nauto disableSync = [](void) noexcept -> int\n{\n std::ios::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return 0;\n}();\n\ntypedef struct TreeNode NodeBT_t;\n\nclass Solution final\n{\nprivate:\n int nbVali... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "class Solution {\npublic:\n int pseudoPalindromicPaths (TreeNode* root) {\n int retVal{0};\n if(root->left == nullptr && root->right==nullptr) return 1;\n isGood(root, {0,0,0,0,0,0,0,0,0,0}, retVal);\n return retVal;\n }\nprivate:\n void isGood(TreeNode* current, vector... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<int,int> mp ;\n int ans = 0 ;\n void solve (auto root){\n if (mp.count (root->val)) mp.erase(root->val) ;\n else mp[root->val]++;\n if (!root->left && !root->right){\n ans += mp.size() <= 1;\n }\n if(root->lef... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "// Idea: Tree Traversal. just maintain the OddSet of numbers with odd-counts.\nclass Solution {\npublic:\n int pseudoPalindromicPaths(TreeNode* root) {\n int palins = 0; // count of pseudo palindromes\n unordered_set<int> oddSet;\n traverse(root, oddSet, palins);\n return pal... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 3 | {
"code": "class Solution {\npublic:\n map<int,int> mp ;\n int ans = 0 ;\n void solve (auto root){\n if (mp.count (root->val)) mp.erase(root->val) ;\n else mp[root->val]++;\n if (!root->left && !root->right){\n ans += mp.size() <= 1;\n }\n if(root->left) solve (... |
1,568 | <p>Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be <strong>pseudo-palindromic</strong> if at least one permutation of the node values in the path is a palindrome.</p>
<p><em>Return the number of <strong>pseudo-palindromic</strong> paths going from the root node to ... | 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.