id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dir = {{1,0},{0,1},{0,-1},{-1,0}};\n bool isvalid(int i,int j,int n,int m){\n return (i>=0 and j>=0 and i<n and j<m);\n }\n bool dfs(int i,int j,vector<vector<int>>& grid){\n int row = grid.size();\n int col = grid[0].size();\... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dir = {{1,0},{0,1},{0,-1},{-1,0}};\n bool isvalid(int i,int j,int n,int m){\n return (i>=0 and j>=0 and i<n and j<m);\n }\n bool dfs(int i,int j,vector<vector<int>>& grid){\n int row = grid.size();\n int col = grid[0].size();\... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dir = {{1,0},{0,1},{0,-1},{-1,0}};\n\n bool isvalid(int i, int j, int n, int m){\n return (i >= 0 && j >= 0 && i < n && j < m);\n }\n\n bool dfs(int i, int j, vector<vector<int>>& grid){\n int row = grid.size();\n int col = gr... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n int r,c;\n vector<vector<int>>directions{{1,0},{-1,0},{0,1},{0,-1}};\n bool dfs(vector<vector<int>>&grid,int i,int j){\n if(i<0 || i>= r || j<0 || j>= c || grid[i][j] ==1)return false;\n if(i == r-1)return true;\n grid[i][j] =1;\n\n for(auto ... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n int Row;\n int Col;\n vector<vector<int>>directions{{1,0},{-1,0},{0,1},{0,-1}};\n\n bool DFS( vector<vector<int>>&grid,int i,int j)\n {\n if(i<0 ||i>=Row ||j<0 ||j>=Col || grid[i][j]==1)\n {\n return false;\n }\n\n if(i==Row-... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n\n bool dfs(map<pair<int, int>, bool> &visited, int i, int j, vector<vector<int>> &a){\n int n = a.size();\n int m = a[0].size();\n visited[{i, j}] = true;\n if(i == n-1 ) return true;\n vector<int> dir = {1, 0, -1, 0, 1};\n for(int d... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n vector<pair<int, int>> directions = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};\n bool feasible(vector<vector<int>>& cells, int row, int col, int mid){\n vector<vector<int>> matrix(row+1, vector<int>(col+1));\n vector<vector<int>> visited(row+1, vector<int>(col+1));\... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};\n bool check(int mid,int m,int n,vector<vector<int>>& cells){\n vector<vector<int>> grid(m,vector<int> (n,0));\n for(int i=0;i<mid;i++){\n grid[cells[i][0]-1][cells[i][1]-1]=1;\n }\n\n queue<... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n bool helper(int i,int j,vector<vector<int>>&grid,vector<vector<bool>>&visited){\n int m=grid.size();\n int n=grid[0].size();\n if(i==m-1){\n return 1;\n }\n visited[i][j]=1;\n vector<int>v1={0,1,0,-1};\n vector<int>v... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\n int row_ = 0;\n int col_ = 0;\n\n bool solvable(std::vector<std::vector<int>> const& grid, int max) {\n // Start with every item on first row, \n\n std::deque<std::pair<int, int>> queue;\n std::unordered_set<int> visited;\n\n for(int i=0; i<1; ++i) {\... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dir = {{-1, 0 } ,{1, 0 } , {0,1},{0,-1}};\n bool dfs( vector<vector<int>>&days , int i , int j , int row , int col ){\n if(i < 0 || i>= row || j<0 || j>=col || days[i][j]==1) return false ;\n //reached the last row\n if ( i == row-... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dir = {{-1, 0 } ,{1, 0 } , {0,1},{0,-1}};\n bool dfs( vector<vector<int>>&days , int i , int j , int row , int col ){\n if(i < 0 || i>= row || j<0 || j>=col || days[i][j]==1) return false ;\n //reached the last row\n if ( i == row-... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n int dr[4] = {0,0,-1,1};\n int dc[4] = {-1,1,0,0};\n bool solve(int loc, int n, int m, vector<vector<int>>& c){\n loc--;\n vector<vector<int>> grid(n,vector<int>(m,0)), vis(n,vector<int>(m,0));\n for(int i=0; i<=loc;i++){\n grid[c[i][0]-1]... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n\nvector<vector<int>> directions = {{0,1},{0,-1}, {1,0},{-1,0}};\n bool dfs(int r, int c, int row, int col, vector<vector<int>> &mat){\n mat[r][c] = 1;\n if(r==row-1) return true;\n for(auto dir:directions){\n int dr = r+dir[0];\n int... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n\nvector<vector<int>> directions = {{0,1},{0,-1}, {1,0},{-1,0}};\n bool dfs(int r, int c, int row, int col, vector<vector<int>> &mat){\n mat[r][c] = 1;\n if(r==row-1) return true;\n for(auto dir:directions){\n int dr = r+dir[0];\n int... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n int nbr[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};\n bool psbl(int days, int row, int col, vector<vector<int>>& cells){\n set<pair<int, int>> vis;\n // cout<<days<<endl;\n for(int i=0; i<=min(days, (int)cells.size()-1); i++){\n vis.insert({... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n bool bfs(int mid,vector<vector<int>> &cells,int row,int col){\n vector<vector<int>> vis(row,vector<int>(col,0));\n queue<pair<int,int>> q;\n vector<vector<int>> grid(row,vector<int>(col,0));\n for(int i=0;i<mid;i++){\n int x=cells[i][0]-... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "int nx[5] ={1,0,-1,0,1};\nclass Solution {\npublic:\n // void print(vector<vector<int>> &num){\n // for(vector<int> a:num){\n // cout << \"(\" << a[0] << \" \" << a[1] << \") \"; \n // }\n // cout << endl;\n // }\n // bool check(vector<vector<bool>>& m, vector<vecto... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "int nx[5] ={1,0,-1,0,1};\nclass Solution {\npublic:\n void generate(vector<vector<bool>> &m, vector<vector<int>>& cells, int mid){\n int row = m.size();\n int col = m[0].size();\n vector<vector<bool>> temp(row, vector<bool> (col, false));\n m = temp;\n for(int i = 0 ; ... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n\n bool solve(vector<vector<int>>& cells, int lastDay, int row, int col) {\n vector<vector<int>> graph(row,vector<int>(col,0));\n vector<vector<bool>> visited(row,vector<bool>(col,false));\n\n for(int i=0; i <= lastDay; i++) {\n graph[cells[i][0... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n bool nerd(int row, int col, vector<vector<int>>& cells,int mid){\n vector<vector<int>>v(row,vector<int>(col,0));\n for(int i=0;i<=mid;i++){\n v[cells[i][0]-1][cells[i][1]-1]=1;\n }\n queue<vector<int>>q;\n vector<vector<int>>vis(r... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "int nx[5] ={1,0,-1,0,1};\nclass Solution {\npublic:\n // void print(vector<vector<int>> &num){\n // for(vector<int> a:num){\n // cout << \"(\" << a[0] << \" \" << a[1] << \") \"; \n // }\n // cout << endl;\n // }\n // bool check(vector<vector<bool>>& m, vector<vecto... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "class Solution {\npublic:\n bool isDoable(vector<vector<int>> g,int m,int r,int c){\n vector<vector<int>> vis(r,vector<int> (c,0));\n vector<int> dx={-1,0,1,0};\n vector<int> dy={0,1,0,-1};\n queue<vector<int>> q;\n for(int i=0;i<c;++i){\n if(g[0][i]>m){\n ... |
2,101 | <p>There is a <strong>1-based</strong> binary matrix where <code>0</code> represents land and <code>1</code> represents water. You are given integers <code>row</code> and <code>col</code> representing the number of rows and columns in the matrix, respectively.</p>
<p>Initially on day <code>0</code>, the <strong>entire... | 3 | {
"code": "int nx[5] ={1,0,-1,0,1};\nclass Solution {\npublic:\n // void print(vector<vector<int>> &num){\n // for(vector<int> a:num){\n // cout << \"(\" << a[0] << \" \" << a[1] << \") \"; \n // }\n // cout << endl;\n // }\n // bool check(vector<vector<bool>>& m, vector<vecto... |
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>
<... | 1 | {
"code": "class Solution {\npublic:\n int maxLength(vector<string>& arr) {\n \n unordered_set<bitset<26>> set;\n for(auto s : arr) {\n bitset<26> bs;\n bool valid = true;\n unordered_set<bitset<26>> curset = set;\n for(auto c : s) {\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>
<... | 1 | {
"code": "class Solution {\npublic:\nunordered_map<char,bool> mp;\nbool checks(string s){\n for(int j=0;j+1<s.length();j++){\n if(mp[s[j]]==true || s[j] == s[j+1]){\n return false;\n }\n }\n if(mp[s[s.length()-1]]){\n return false;\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>
<... | 1 | {
"code": "class Solution {\npublic:\n unordered_map<int, int> mp; // Memoization with bitmask as the key\n\n // Recursive function to find the maximum length\n int func(int ind, vector<string>& arr, int taken) {\n if (ind == arr.size()) return 0; // Base case: end of the array\n\n if (mp.find(... |
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>
<... | 1 | {
"code": "class Solution {\npublic:\n \n void addstring(unordered_set<bitset<26>>& curset, string s) {\n bitset<26> bs;\n bs.reset();\n for(int i = 0; i < s.size(); i++) {\n int idx = s[i] - 'a';\n if(bs[idx] == 1)\n return;\n bs[idx] = 1;\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>
<... | 1 | {
"code": "class Solution {\npublic:\n bool duplicate(string& str, string &temp) {\n int arr[26] = {0};\n for (auto &i : temp) {\n if (arr[i - 'a'] > 0) return true;\n arr[i - 'a']++;\n }\n for (auto &i : str) {\n if (arr[i - 'a'] > 0) return true;\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>
<... | 1 | {
"code": "class Solution {\npublic:\n unordered_map <string, int> dp;\n\n int maxlen_con(vector<string>& arr, int n, int ind , string curr)\n {\n if(ind==n) return curr.size();\n\n if(dp.find(curr) != dp.end()) return dp[curr];\n\n int cnt[26]={0};\n for(char ch :arr[ind])\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>
<... | 1 | {
"code": "class Solution {\npublic:\n map<int,map<int,int>>dp;\n int rec(int ind,int mask,vector<string>&arr){\n if(ind==arr.size()) return 0;\n if(dp.find(ind)!=dp.end() && dp[ind].find(mask)!=dp[ind].end()) return dp[ind][mask];\n\n int ans=rec(ind+1,mask,arr);\n\n bool flag=true;... |
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>
<... | 1 | {
"code": "class Solution {\npublic:\n int maxLength(vector<string>& arr) {\n int maxLength = 0;\n backTrack(arr, \"\", 0, maxLength);\n return maxLength;\n }\n\n void backTrack(const vector<string>& arr, string current, int start, int& maxLength) {\n if (maxLength < current.lengt... |
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>
<... | 1 | {
"code": "class Solution {\npublic:\n bool check(string &s1, string& s2) {\n int arr[26] = {0};\n \n for(char &ch : s1) {\n if(arr[ch-'a'] > 0)\n return false;\n arr[ch-'a']++;\n }\n \n for(char &ch : s2) {\n if(arr[ch-'a'] ... |
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>
<... | 1 | {
"code": "class Solution {\npublic:\n bool check(string &s1, string& s2) {\n int arr[26] = {0};\n \n for(char &ch : s1) {\n if(arr[ch-'a'] > 0)\n return false;\n arr[ch-'a']++;\n }\n \n for(char &ch : s2) {\n if(arr[ch-'a'] ... |
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>
<... | 1 | {
"code": "class Solution {\npublic:\n int maxLength(vector<string>& arr) {\n vector<bool> use (26, false);\n return helper(arr, use, 0, 0);\n }\n\n int helper(vector<string>& arr, vector<bool>& use, int i, int cnt) {\n if (i == arr.size()) {\n return cnt;\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>
<... | 1 | {
"code": "class Solution {\npublic:\n\nint ans(vector<string>& a, int i, unordered_map<char,int> & x)\n{\n if(i==a.size())\n return 0;\n\n int t=0;\n\n bool sexy=true;\n\n for(char c : a[i])\n {\n if(x.count(c))\n {\n sexy=false;\n break;\n }\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>
<... | 1 | {
"code": "class Solution {\npublic:\nbool isduplicate(string s1,string s2){\n vector<char>c(26,0);\n for(auto it:s1){\n if(c[it-'a']>0){\n return true;\n }\n c[it-'a']++;\n }\n for(auto it:s2){\n if(c[it-'a']>0){\n return true;\n }\n }\n retu... |
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>
<... | 1 | {
"code": "class Solution {\n\n private:\n int maxSize=0;\npublic:\n \n bool hasUnique(string &s1,string &s2){\n\n vector<bool> hash(26,false);\n \n\n\n for(int i=0;i<s1.size();i++){\n if(hash[s1[i]-'a']) return false;\n hash[s1[i]-'a']=true;\n }\n for(... |
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>
<... | 1 | {
"code": "class Solution {\npublic:\n int maxHelper(vector<string>& arr, int i,\n vector<int>& state, int count) {\n if (i >= arr.size()) {\n return count;\n }\n bool dup = false;\n vector<int> temp(26, 0);\n for (int j = 0; j < arr[i].length(); 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>
<... | 1 | {
"code": "class Solution {\npublic:\n int solve(vector<string> &arr,int i,vector<int> &dp){\n if(i == arr.size()){\n int ans = 0;\n for(auto k : dp) ans += k;\n\n return ans;\n }\n\n int ch1 = solve(arr,i+1,dp);\n vector<int> temp(26,0);\n for(au... |
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>
<... | 1 | {
"code": "class Solution {\npublic:\n int maxi = 0;\n int n;\n \n bool isPossible(vector<int>& freq, string str) {\n vector<int> temp(26, 0);\n for (char s : str) {\n if (freq[s - 'a'] == 1 || temp[s - 'a'] == 1)\n return false;\n temp[s - 'a'] = 1;\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>
<... | 1 | {
"code": "class Solution {\npublic:\n bool hasDuplicate(string& s1, string& s2){\n vector<int> freq(26, 0);\n for(char& ch : s1){\n if(freq[ch-'a'] > 0) return true; //s1 me duplicate characters\n freq[ch-'a']++;\n }\n\n for(char& ch : s2){\n if(freq[ch... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool unique(string str){\n unordered_set<char> st(str.begin(), str.end());\n return st.size() == str.size();\n }\n int solve(int ind, const string &curr, vector<string> &arr){\n if(!unique(curr)) return 0;\n int ans = curr.size();\n fo... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\nint ans=0;\nbool isunique(string tem){\n unordered_set<char>seen;\n for(char ch: tem)seen.insert(ch);\n return(tem.size()==seen.size());\n}\nvoid backtrack(vector<string>&nums,string tem,int idx){\n if(!isunique(tem)){\n return;\n }\n ans=max(ans,(int)tem... |
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>
<... | 2 | {
"code": "class Solution {\n bool isUnique(string s) {\n unordered_set<char> set;\n set.insert(s.begin(), s.end());\n return s.size() == set.size();\n }\npublic:\n int maxLength(vector<string>& arr) {\n vector<string> res = {\"\"};\n int best = 0;\n for(int i =0 ; 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>
<... | 2 | {
"code": "class Solution {\npublic:\n unordered_map<string, int> mp;\n bool common(string& str1, string& str2) {\n vector<int> vec(26, 0);\n\n for (auto& ch : str1) {\n if (vec[ch - 'a'] > 0)\n return true;\n vec[ch - 'a']++;\n }\n\n for (auto& c... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool isUnique(string s){\n unordered_set<char> se;\n\n for(int i=0;i<s.size();i++)\n {\n if(se.count(s[i])) return false;\n se.insert(s[i]);\n }\n return true;\n }\n void dfs(vector<string>& arr, string path, int ... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\n map<pair<int,string>,int> mp;\n bool hasdup(string &s1,string &s2)\n {\n vector<int> ch(26,0);\n for(auto &it: s1)\n {\n if(ch[it-'a']>0)\n {\n return true;\n }\n\n ch[it-'a']++;\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>
<... | 2 | {
"code": "class Solution {\n int dfs(int idx, vector<string>& arr, vector<int> vis){\n if(idx == arr.size()) return 0;\n int skip = dfs(idx+1, arr, vis); \n for(char c : arr[idx]){\n if(vis[c - 'a']) return skip;\n vis[c - 'a'] = 1;\n }\n int noskip = arr[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>
<... | 2 | {
"code": "class Solution {\n int dfs(int idx, vector<string>& arr, vector<int> vis){\n if(idx == arr.size()) return 0;\n int skip = dfs(idx+1, arr, vis); \n for(char c : arr[idx]){\n if(vis[c - 'a']) return skip;\n vis[c - 'a'] = 1;\n }\n int noskip = arr[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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool isUnique(string& s) {\n vector<int> v(26, 0);\n for (char c : s) {\n if (v[c - 'a']++ > 0) {\n return false;\n }\n }\n return true;\n }\n bool hasduplicate(string& s1, string& s2){\n vector<int... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool isunq(string outt){\n map<char,int>m;\n for(auto i:outt){\n if(m.find(i)!=m.end()){\n return false;\n }\n m[i]++;\n }\n return true;\n }\n void solve(vector<string>& arr, int index,int &ans... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool isUnique(string &str){\n vector<int> dict(26, 0);\n for(auto c : str){\n dict[c - 'a']++;\n if(dict[c - 'a'] > 1) return false;\n }\n return true;\n }\n void rec(vector<string>& arr, int &n, int i, string res, int &... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool isUnique(string& s) {\n vector<int> charCount(26, 0);\n\n for (char c : s) {\n int index = c - 'a';\n if (charCount[index] > 0) {\n return false;\n }\n charCount[index]++;\n }\n\n retu... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool hasduplicate(string s1,string s2){\n vector<int>v(26,0);\n for(char c:s1){\n v[c-'a']++;\n if(v[c-'a']>1)return true;\n }\n for(char c:s2){\n if(v[c-'a']>0)return true;\n }\n return false;\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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool check(string& s){\n vector<int>arr(26,0);\n int i=0;\n bool ans=true;\n\n while(i<s.length()){\n int e=s[i]-'a';\n arr[e]++;\n i++;\n }\n\n for(int i=0;i<26;i++){\n int e=arr[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>
<... | 2 | {
"code": "//Backtracking\nclass Solution {\npublic:\n int solve(int index,vector<string> &ans,vector<string> &arr)\n {\n if(index>=arr.size()) return 0;\n\n ans.push_back(arr[index]);\n unordered_map<char,int> m;\n for(int i=0;i<ans.size();i++)\n {\n for(int j=0;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>
<... | 2 | {
"code": "class Solution {\npublic:\n int helper(int idx, vector<string>& arr, vector<string>& currResult) {\n unordered_map<char, int> list;\n if(idx<arr.size()){\n cout<<idx<<\" \"<<currResult.size()<<endl;\n currResult.push_back(arr[idx]);\n }\n else {\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>
<... | 2 | {
"code": "class Solution {\npublic:\n void find(int i, int curr, unordered_map<char, int>& chars,\n vector<string>& arr, int& ans) {\n if (i == arr.size()) {\n ans = max(ans, curr);\n return;\n }\n\n bool canBeAdded = true;\n unordered_set<char> st;\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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool check(string ds){\n if(ds.size() == 0) return true;\n unordered_map<char, int> m;\n for(int i =0; i<ds.size(); i++){\n m[ds[i]]++;\n if(m[ds[i]] > 1)return false;\n }\n return true;\n }\n\n void solve(vector<... |
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>
<... | 2 | {
"code": "#include <vector>\n#include <string>\n#include <unordered_map>\n\nclass Solution {\npublic:\n // Function to check if two strings have any common characters\n bool hasCommon(const std::string &cstr, const std::string &tmp) {\n std::vector<int> a(26, 0);\n for (const auto &ch : cstr) {\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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool chk(string &s, string &t)\n {\n vector<int>f1(26, 0), f2(26, 0);\n for(auto it : s) f1[it - 'a']++;\n for(auto it : t) f2[it - 'a']++;\n // for(auto it : f1) cout<<it<<\" \";\n // cout<<endl;\n for(int i =0; i < 26; 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>
<... | 2 | {
"code": "class Solution {\npublic:\n\n // Can also be solved using bit manipulation\n\n unordered_set<char>st;\n\n unordered_map<string,int>mp;\n\n bool canTake(string a, string b){\n\n st.clear();\n\n for(int i=0; i<a.length(); i++){\n st.insert(a[i]);\n }\n\n for... |
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>
<... | 2 | {
"code": "class Solution {\npublic:\n bool isunique(string str){\n unordered_set<char> char_set;\n for(char c : str){\n if( char_set.count(c)){\n return false;\n }\n char_set.insert(c);\n }\n return true;\n }\nint maxlen(vector<string>& arr... |
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 insertinto(string s,vector<int>&arr)\n {\n int n=s.size();\n vector<int>trr(26);\n trr=arr;\n \n for(int i=0;i<n;i++)\n {\n if(trr[s[i]-'a']>0) return false;\n else {\n trr[s[i]-'a']+=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 n;\nint ans=0;\n \n void findSub(vector<string> &arr, int i, vector<int>mp, int maxL)\n {\n \n if(i==n)\n return ;\n \n \n vector<int> mp1=mp;\n \n \n int sz=arr[i].length(); \n int j=0;\... |
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 &s1,string &s2){\n unordered_map<char,int>mp;\n for(auto it:s1){\n if(mp[it]>0)return true;\n mp[it]++;\n }\n for(auto it:s2){\n if(mp[it]>0)return true;\n }\n return false;\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\nbool isdup(string &s1, string &s2){\n unordered_map<char,int>mp;\n for(char & ch : s1){ // {\"aa\", \"bb\"} special case\n if(mp[ch-'a'] > 0){\n return true;\n }\n mp[ch-'a']++;\n }\n\n for(char & ch: s2){\n if(mp[ch-'a'] > 0){\... |
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 a, string b)\n {\n int n = a.size(), m = b.size();\n unordered_set<char> st;\n //edge = aa,bc\n \n for(int i=0;i<n;i++)\n {\n if(st.find(a[i])!=st.end())\n { \n cout... |
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 bool check(string st,string t)\n {\n unordered_set<char> s;\n for(char ch : st)\n {\n if(s.find(ch)!=s.end())\n return false;\n\n s.insert(ch);\n }\n for(char ch : t)\n {\n if(s.find(ch)!=s.end())... |
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 n;\n int solve(vector<string>& arr,int ind,unordered_set<char>& st){\n if(ind==n){\n return st.size();\n }\n \n unordered_set<char> copyset=st;\n bool unique=true;\n for(auto &c:arr[ind]){\n if(copyset.cou... |
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 int ans=0;\n map<pair<int,string>,int>dp;\n int func(int ind,vector<string>& arr,string str,int n)\n {\n if(ind==n)\n {\n return 0;\n }\n if(dp.find({ind,str})!=dp.end())return dp[{ind,str}];\n unordered_map<char,int>mpp;... |
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 map<pair<int,string>,int>dp;\n int func(int ind,vector<string>& arr,string str,int n)\n {\n if(ind==n)\n {\n return 0;\n }\n if(dp.find({ind,str})!=dp.end())return dp[{ind,str}];\n unordered_map<char,int>mpp;... |
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 ise(string g){\n map<char,int>mp;\n for(int i=0;i<g.size();i++)mp[g[i]]++;\n return mp.size()==g.size();\n}\nbool is(string m,string n){\n m+=n;\n map<char,int>mp;\n for(int i=0;i<m.size();i++)mp[m[i]]++;\n return mp.size()==m.size();\n}\nvoid solve(int ... |
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 void find(vector<string>&arr, unordered_map<char, int>&mp, int start, \n int dont, int &len, int temp){\n if(start == arr.size()){\n if(temp > len) len = temp;\n return;\n }\n int i;\n unordered_map<char, int>temp2;\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:\nbool hasDuplicate(string &s1,string &s2){\n int arr[26]={0};\n for(char&ch:s1){\n if(arr[ch-'a']>0) return true;\n arr[ch-'a']++;\n }\n for(char&ch:s2){\n if(arr[ch-'a']>0) return true;\n \n }\n return false;\n}\n\nint solve(int i,vector<string>arr,string temp,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\n bool isduplicate(string &s1,string &s2){\n int arr[26]={0};\n for(char &ch: s1){\n if(arr[ch-'a']>0){\n return true;\n }\n arr[ch-'a']++;\n }\n \n for(char &ch: s2){\n if(arr[ch-'a... |
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 rep(string s) {\n unordered_set<char>cs;\n for(char c:s) {\n if(cs.find(c)!=cs.end()) {\n return true;\n }\n cs.insert(c);\n }\n return false;\n }\nbool check(string a,string s1)\n{\n unorder... |
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 // check two string do not share any character\n bool checkUnique(string first, string second)\n {\n map<char, bool> mp;\n for(char val : first)\n {\n if(mp.find(val) != mp.end()) return false;\n mp[val] = true;\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{\npublic:\n string curr;\n int ans;\n void rec(int level, vector<string> &arr)\n {\n if (level == arr.size())\n {\n vector<int> freq(26, 0);\n for (auto i : curr)\n {\n freq[i - 'a']++;\n }\n fo... |
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(int index, string s, vector<string>& arr)\n {\n if(index==arr.size())\n {\n return 0;\n }\n\n map<char, int>m;\n for(auto it : s)\n {\n m[it]++;\n }\n bool aa =true;\n set<char>q... |
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 duplicate(string s1,string s2)\n {\n int count[26]={0};\n\n for(int i=0;i<s1.length();i++)\n {\n count[s1[i]-'a']++;\n }\n\n for(int i=0;i<s2.length();i++)\n {\n count[s2[i]-'a']++;\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 unordered_map<string,int>m;\n bool hasDup(string s1, string s2)\n {\n int frq[26] = {0};\n for(char ch:s1)\n {\n if(frq[ch-'a']>0)return true;\n frq[ch-'a']++;\n }\n for(auto ch:s2)\n {\n if(frq... |
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 canITake(string& first, string& second){\n set<char> st;\n set<char> ss;\n for(int i = 0; i < first.size(); i ++){\n if(st.find(first[i]) != st.end()) return false;\n st.insert(first[i]);\n }\n for(int i = 0; i < s... |
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 n;\n bool hasUniqueCharacters(const string& s) {\n unordered_map<char, int> charCount;\n for (char ch : s) {\n if (++charCount[ch] > 1) return false;\n }\n return true;\n }\n bool comapare(string s1,string s2){\n if(s... |
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 unordered_map<string,int>mp;\n bool isPossible(string& s) {\n set<char> st(s.begin(), s.end());\n return st.size() == s.size();\n }\n \n int solve(int i, vector<string>& arr, string temp) {\n if (i >= arr.size()) {\n return temp.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 {\npublic:\n // vector<int> dp; \n unordered_map< string , int> dp;\n int solve(int idx , string temp , vector<string> &arr, unordered_map<char,int> mp ){\n if(idx < 0) return 0;\n\n if(idx == 0 ){\n for(int i = 0 ; i < arr[0].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\n bool unique(string A, string B) {\n unordered_set<char> stA;\n for (char c : A) {\n if (stA.find(c) != stA.end()) return false;\n stA.insert(c);\n }\n\n unordered_set<char> stB;\n for (char c : B) {\n if (s... |
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 checkduplicate(string s1,string s2){\n map<char ,int> mp1;\n map<char ,int> mp2;\n\n for(auto ch:s1){\n mp1[ch]++;\n if(mp1[ch]>1)return true;\n }\n\n for(auto ch:s2){\n if(mp1.find(ch)!=mp1.end())retu... |
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 s1,string s2){\n set<char> s;set<char> S;\n for(int i=0;i<s1.size();i++) s.insert(s1[i]);\n for(int i=0;i<s2.size();i++) S.insert(s2[i]);\n if(s.size()<s1.size() || S.size()<s2.size()) return true;\n for(int i=0;i<s2... |
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 // basic dp problem\n bool checkunike(string t){\n unordered_map<int,int>freq;\n for(int i=0;i<t.length();i++){\n freq[t[i]]++;\n if(freq[t[i]] >1){\n return false;\n }\n \n }\n return true;... |
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 poss(const string &s, const string &a) {\n unordered_set<char> p(s.begin(), s.end());\n for (char c : a) {\n if (p.find(c) != p.end()) {\n return false;\n }\n }\n return true;\n }\n bool check(string ... |
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 bool overLap(set<char> &st, string &s){\n map<char,int> mp;\n for(char c: st) mp[c]++;\n for(char c: s) mp[c]++;\n\n for(auto &[k,v]: mp){\n if(v > 1) return true;\n }\n return false;\n }\n\n int f(int i, vector<string> &arr, ... |
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 &s1,string &s2) {\n vector<int> freq(26, 0);\n for (char c : s1) {\n freq[c-'a']++;\n if (freq[c - 'a'] > 1) {\n return true;\n }\n } \n for (char c : s2) {\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 hasduplicate(string &s1,string &s2) {\n vector<int> freq(26, 0);\n for (char c : s1) {\n if (freq[c - 'a']++ > 0) {\n return true;\n }\n } \n for (char c : s2) {\n if (freq[c - 'a']++ > 0)... |
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 unordered_map<string, int> mpp;\n\n bool isPos(string s1, string s2)\n {\n vector<int> hash(26, 0);\n for(int i=0; i<s1.size(); i++)\n {\n if(hash[s1[i]-'a'] != 0) return false;\n hash[s1[i]-'a']++;\n }\n\n for(int i=0; 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:\nint n;\nbool isduplicate(string s,string temp){\n map<char,bool>mp,check;\n for(int i=0;i<s.length();i++){\n if(check[s[i]]==true){\n return true;\n }\n check[s[i]]=true;\n }\n for(int i=0;i<temp.length();i++){\n mp[temp[i]]=true... |
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 // Check if the string `b` can be concatenated to `a` without having any common characters\n bool check(string& a, string& b) {\n unordered_set<char> charsInA(a.begin(), a.end());\n for (char ch : b) {\n if (charsInA.find(ch) != charsInA.end()) {\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:\nint maxlen=0;\nvector<string> arr1;\n void backtrack(unordered_map<char,int> mp1,int i,string s){\n int a=s.length();\n maxlen=max(a,maxlen);\n\n if(i>=arr1.size()){\n return;\n }\n \n backtrack(mp1,i+1,s);\n\n for(int j... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.