id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n unordered_map<char,int> table;\n for(auto c:p)\n {\n table[c]++;\n }\n int left=0,right=0,counter=table.size();\n while(right<s.length())\n {... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n\n // vector<int> ans ;\n // unordered_map <char, int> mp1, mp2 ;\n\n // for(int i=0 ; i < p.size() ; i++){\n // mp1[p[i]]++ ; \n // }\n\n // int i = 0 ;\n // int j = 0 ;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "\n class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int n = s.size();\n \n map<char, int> mp;\n int k = p.size();\n for(int i = 0; i < k; i++){\n mp[p[i]]++;\n }\n \n int count = mp.size();\n \n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n unordered_map<char,int> umap;\n vector<int> ans;\n int i=0,j=0;\n\n for(int i=0;i<p.size();i++){\n umap[p[i]]++;\n }\n\n int k = p.size();\n int cnt = umap.size();\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int n = p.size();\n int tot = s.size();\n \n map<char, int> mp;\n \n for(char &x: p){\n mp[x]++;\n }\n\n map<char, int> temp;\n int start_index=0;\n\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n\tvector<int> search(string pat, string txt) {\n\t // code here\n\t map<char,int>mp; vector<int> ans;\n\t //char,frew\n\t for(auto it:pat)\n\t {\n\t mp[it]++;\n\t }\n\t int k=pat.size();\n\t int i=0;\n\t int j=0; int count=mp.size();\n\t while... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int n = s.size(), m = p.size();\n unordered_map<char, int> freq;\n for (auto& c : p) {\n freq[c]++;\n }\n vector<int> ans;\n queue<int> q;\n for (int i=0; i<n; i++) {\... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "#pragma GCC optimize(\"03\", \"unroll-loops\")\nauto init = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 'c';}();\n\nclass Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int n = s.size(), m = p.size();\n unordered_map<char, int> freq;\n for... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> m(128, 0);\n\n for (auto c : p) m[c]++;\n\n // dump\n for (int i= 0; i < 128; i++) cout << i << \": \" << m[i] << endl;\n\n vector<int> cur(128, 0);\n vector<int> res;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n if(p.size()>s.size())\n {\n return {};\n }\n s.push_back('a');\n vector<int>ans;\n int n = p.size();\n int i = 0,j= 0;\n vector<int>mp(26,0);\n for(auto ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n // convert p to a map of unique letters to counts\n \n std::unordered_map<char, int> letterCounts(p.length());\n \n for (int i = 0; i < p.length(); ++i)\n {\n if (letterCount... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "// 438. Find All Anagrams in a String\n// https://leetcode.com/problems/find-all-anagrams-in-a-string/description/\n\nclass Solution {\npublic:\n\tbool equalHashmaps(unordered_map<char, int>& sm, unordered_map<char, int>& pm) {\n\n\t\tfor (int i = 0 ; i < 256 ; i++) {\n\n if (sm[i] != pm[i])\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int l=0,r=0,count=0;\n vector<int> res;\n unordered_map<char,int> ref,anagram;\n\n for (auto i: p) ref[i]++;\n\n while (r < s.length()){\n if (ref.find(s[r]) != ref.end()){\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int l=0,r=0,count=0,slen=s.length(),plen=p.length();\n vector<int> res;\n \n unordered_map<char,int> ref,anagram;\n\n if (plen > slen) return res;\n \n for (auto i: p) ref[i]++;\... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n bool check(unordered_map<char , int >&mp1, unordered_map<char , int>&mp2){\n if(mp1.size() != mp2.size())return false;\n\n for(auto it : mp2){\n if(it.second != mp1[it.first])return false;\n }\n return true;\n }\n vector<int> findAnagr... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(const string& s, const string& p) {\n unordered_map<char, int> cnt;\n unordered_map<char, int> pFreq;\n\n for(char c : p)\n ++pFreq[c];\n\n vector<int> res;\n for(int i = 0; i < s.size(); ++i)\n {\n... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n std::vector<int> findAnagrams(const std::string& s, const std::string& p) {\n std::unordered_map<char, int> pChars{};\n for (const auto i: p) {\n ++pChars[i];\n }\n std::vector<int> result{};\n std::unordered_map<char, int> curr{}... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int ns = s.size(), np = p.size();\n\n if(ns < np) return {};\n\n unordered_map<char, int> sCounter;\n unordered_map<char, int> pCounter;\n\n for(auto ch: p){\n if(pCounter.find(ch) ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n unordered_map<char, int> s_anagram;\n unordered_map<char,int> p_anagram;\n for(int i=0;i<p.size();i++)\n {\n p_anagram[p[i]]++;\n }\n//sliding window k con... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 2 | {
"code": "class Solution {\npublic:\n \n \n vector<int> findAnagrams(string s, string p) {\n vector<int>v;\n int k=p.length();\n int n=s.length();\n unordered_map<int,int>m;\n unordered_map<int,int>mp;\n for(int i=0;i<k;i++)\n {\n m[p[i]]++;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n unordered_map<char, int> letter_to_count_needed;\n vector<int> start_indexes;\n for (char c : p) {\n letter_to_count_needed[c]++;\n }\n for (int i = 0; i < s.size(); i++) {\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n unordered_map<char, int> letter_to_count_needed;\n vector<int> start_indexes;\n for (char c : p) {\n letter_to_count_needed[c]++;\n }\n for (int i = 0; i < s.size(); i++) {\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n std::vector<int> results;\n std::map<char, int> p_count;\n for (int i = 0; i < p.length(); ++i) {\n const char cur = p[i];\n UpdateOrInsert(cur, p_count);\n }\n\n std::ma... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n if (p.size() > s.size()) return ans;\n\n // Frequency map for characters in p\n map<char, int> pCount;\n for (char ch : p) {\n pCount[ch]++;\n }\n\n // Frequency map for characters... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n // unordered_set<string> st;\n // vector<int> res;\n // if(s.size()<p.size())\n // return res;\n // sort(p.begin(),p.end());\n // st.insert(p);\n // int sw = p.size();\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n // unordered_set<string> st;\n // vector<int> res;\n // if(s.size()<p.size())\n // return res;\n // sort(p.begin(),p.end());\n // st.insert(p);\n // int sw = p.size();\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int sSize = s.length();\n int pSize = p.length();\n \n vector<int> answer;\n \n if(pSize > sSize) {\n return answer;\n }\n \n vector<int> sMap(26, 0);\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n \n vector<int> res;\n \n int ns = s.length();\n int np = p.length();\n \n if(ns<np) {\n return res;\n }\n \n unordered_map<char,int> mp;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n bool check(map<char, int>& mp1, map<char, int>& mp){\n for(auto it: mp1){\n char key = it.first;\n int freq = it.second;\n\n if(freq > mp[key]){\n //gadbad hai bhai\n return true;\n }\n }\... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n\n/*\n Solution :\n\n 1.Sliding Window approach.\n\n 2. Store frequency of charcter in array or map.\n\n 3. s = \"cbaebabacd\", p = \"abc\".\n here sliding window of size=3;\n\n i] cbaebabacd (cba) i=0; ans\n ---\n ii] cbaebabacd (bae) i=1;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n if(p.length()>s.length()) return {};\n int pl=p.length();\n map<char,int>mp;\n for(auto it:p)\n mp[it]++;\n map<char,int>mp1;\n for(int i=0;i<pl;i++)\n mp1[s[i]]++;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n\n/*\n Solution :\n\n 1.Sliding Window approach.\n\n 2. Store frequency of charcter in array or map.\n\n 3. s = \"cbaebabacd\", p = \"abc\".\n here sliding window of size=3;\n\n i] cbaebabacd (cba) i=0; ans\n ---\n ii] cbaebabacd (bae) i=1;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n if(p.size()>s.size())\n return ans; \n int window_size = p.size();\n int counter=0;\n map<char,int> table;\n for(int i=0;i<p.size();i++){\n if(t... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n \n vector<int> result;\n int sLen = s.size(), pLen = p.size();\n if (sLen < pLen) return result;\n\n unordered_multiset<char> pSet(p.begin(), p.end());\n unordered_multiset<char> window... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n unordered_multiset<char> p_set;\n\n for (char c : p) {\n p_set.insert(c);\n }\n \n unordered_multiset<char> s_set;\n int left = 0;\n int right = p.size();\n for ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n map<char,int> mp1;// s\n map<char,int> mp2;// p\n int n=s.length();\n int k=p.length();\n int i=0,j=0;\n \n for(char ch: p){\n mp2[ch]++;\n }\n\n vector<... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "#include<bits/stdc++.h>\nclass Solution {\npublic:\n vector<int> findAnagrams(string s, string p) \n {\n map<char,int>mp;\n for(int k =0;k<p.size();k++)\n {\n mp[p[k]]++;\n }\n vector<int>v;\n map<char,int>m;\n int k = p.length();\n i... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "#include<bits/stdc++.h>\nclass Solution {\npublic:\n vector<int> findAnagrams(string s, string p) \n {\n map<char,int>mp;\n for(int k =0;k<p.size();k++)\n {\n mp[p[k]]++;\n }\n vector<int>v;\n map<char,int>m;\n int k = p.length();\n i... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n if(p.length()>s.length())\n return {};\n\n return checkInclusion(p,s);\n \n }\n vector<int> checkInclusion(string s1, string s2) {\n if(s2.length()<s1.length())\n return {};\n\n... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n list<char> anagram;\n vector<int> result;\n \n unordered_map<char, int> p_ft;\n unordered_map<char, int> anagram_ft;\n \n for(auto letter: p)\n p_ft[letter]++;\n\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int m = s.length(), n = p.length();\n if (m < n) return vector<int>();\n \n map<char, int> cnt;\n for (char ch : p) --cnt[ch];\n \n for (int i = 0; i < n-1; ++i) {\n char ch = s[i];\n ++cnt[ch];\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n multiset<char>st(p.begin(),p.end()),st1;\n vector<int>v;\n int p1 = 0;\n for(int i = 0; i < s.size();i++){\n if(st.count(s[i])){\n st1.insert(s[i]);\n }\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int l=0,r=0;\n int m=p.size();\n map<char,int> mp,mp1;\n for(int i=0;i<m;i++)\n {\n mp[p[i]]++;\n }\n mp1=mp;\n int n=s.size();\n vector<int> res;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) \n {\n int ssize = s.size();\n int psize = p.size();\n if (psize > ssize)\n return {};\n\n vector<int> result;\n const multiset<char> chars{ p.cbegin(), p.cend() };\n multiset... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "#define vi vector<int>\nclass Solution {\npublic:\n bool isAnagram(vi freq1, vi freq2){\n for(int i=0; i<freq1.size(); i++){\n if(freq1[i] != freq2[i]){\n return false;\n }\n }\n return true;\n }\n vector<int> findAnagrams(string s, string ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n // unordered_set<string> st;\n // vector<int> res;\n // if(s.size()<p.size())\n // return res;\n // sort(p.begin(),p.end());\n // st.insert(p);\n // int sw = p.size();\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n // unordered_set<string> st;\n // vector<int> res;\n // if(s.size()<p.size())\n // return res;\n // sort(p.begin(),p.end());\n // st.insert(p);\n // int sw = p.size();\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> res;\n if (p.size() > s.size()) {\n return res;\n }\n\n map<char, int> m;\n for (char c : p) {\n m[c] -= 1;\n }\n\n for (int i = 0; i < p.size()... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\nvector<int> findAnagrams(string s, string p) {\n map<char,int>mp;\n multiset<char>mt;\n vector<int>ans;\n for(int i=0;i<p.size();i++){\n mp[p[i]]++;\n mt.insert(s[i]);\n }\n //p ka size \n //set ka maxm2 26\n //i-m ki window minus\n bool c... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int psize = p.size();\n if(psize > s.size()){\n return {};\n }\n multiset<char> ms;\n for(char c : p){\n ms.insert(c);\n }\n multiset<char> compare;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n bool same(vector<char>smap, vector<char>pmap){\n for(int i = 0; i < 26; i++)\n if(smap[i]!=pmap[i])\n return false;\n return true;\n }\n vector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n if (p.lengt... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n unordered_map<char,int> mp;\n\n unordered_map<char,set<int>> mp1;\n for(auto it:p){\n mp[it]++;\n }\n\n int i=0,j=0;\n int n=s.size();\n int cnt=0;\n int m=p.... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n int findSum(vector<vector<int>> &prefix, int ind, int left, int right) {\n\n int r = prefix[ind][right];\n int l = 0;\n\n if (left > 0) {\n l = prefix[ind][left - 1];\n }\n\n return r - l;\n } \n bool check(vector<vector<i... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n \n vector<int> pMap(26, 0);\n if (s.size() < p.size()) return ans;\n for(char c : p) pMap[c - 'a']++;\n\n for(int i = 0; i <= s.size() - p.size(); i++) {\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int n=p.size();\n //unordered_map<char,int> um;\n vector<int> um(26,0);\n for(int i=0;i<p.size();i++){\n if(um[p[i]-'a']==0){\n um[p[i]-'a']=1;\n }\n e... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int ss = s.size(), ps = p.size();\n vector<int> res;\n if(ss<ps)\n return res;\n vector<int> pmap(26, 0);\n \n for (char c : p) {\n pmap[c - 'a']++;\n }\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n bool allZero(vector<int>counter){\n for(int &i:counter){\n if(i!=0){\n return false;\n }\n }\n return true;\n }\n vector<int> findAnagrams(string s, string p) {\n int n=s.size();\n vector<int>cnt(26,0);\n for(int i=0;i<p.size();i+... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n\n bool iszero(vector<int>freq){\n for(int i=0;i<freq.size();i++){\n if(freq[i] !=0){\n return false;\n }\n }\n return true;\n }\n\n vector<int> findAnagrams(string s, string p) {\n... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\nbool isAllZero(vector<int> vec){\n for(int &i : vec){\n if(i != 0){\n return false;\n }\n }\n return true;\n}\n vector<int> findAnagrams(string txt, string pat) {\n int n = txt.length();\n\t \n\t vector<int> vec(26,0);\n\t \n\... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\nbool allzero(vector<int>a){\n for(int i=0;i<26;i++){\n if(a[i]!=0)\n return false;\n }\n return true;\n}\n vector<int> findAnagrams(string s, string p) {\n vector<int>a(26,0),ans;\n\n for(int i=0;i<p.size();i++)\n a[p[i]-'a']++;\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution{\npublic:\n bool allzeros(vector<int>v){\n for(auto &i:v){\n if(i!=0)\n return false;\n }\n return true;\n }\n vector<int> findAnagrams(string s, string p) {\n\n vector<int>ans;\n vector<int>v(26,0);\n for(int i=0;i<p.l... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n bool checkAna(vector<int> &a, vector<int> b) {\n for(int i = 0; i < 26; i++) {\n if (a[i] != b[i]) return false;\n }\n return true;\n }\n vector<int> findAnagrams(string s, string p) {\n if(p.size() > s.size())\n {\n ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> out;\n vector<int> map(26,0);\n int s_len = s.size();\n int p_len = p.size();\n\n if(s_len < p_len) return {};\n\n for( int i = 0; i < p_len; ++i ) {\n map[s[i] -... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> result;\n int plen = p.length();\n int slen = s.length();\n if (plen <= slen) {\n unordered_map<char, int> p_hash;\n for (auto c : p) {\n p_hash[c]++;... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> result;\n int plen = p.length();\n int slen = s.length();\n if (plen <= slen) {\n unordered_map<char, int> p_hash;\n for (auto c : p) {\n p_hash[c]++;... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int>vec1(128,0);\n vector<int>res;\n for(int i=0; i<p.size(); i++){\n vec1[p[i]]++;\n }\n\n int left=0, right=0;\n vector<int>temp(128,0);\n while(right<s.size(... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n bool checkAnagram(string &p, string &s, int start, int end){\n\n vector<int> mp(26,0);\n for( char ch: p){\n mp[ch-'a']++;\n }\n\n for(int i= start;i<=end; i++){\n if(mp[s[i] - 'a']<=0) return false;\n mp[s[i] - 'a'... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "#include <vector>\n#include <unordered_set>\n\nclass Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n std::vector<int> start_indices;\n int n = s.size();\n int l = p.size();\n\n std::vector<int> anagram_count(26, 0);\n std::unordered_set<char> ana... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n if (s.length() < p.length())\n return {};\n int n = p.length();\n vector<int> count(26, 0);\n // string hash = \"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\";\n for (char c... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n\n\n\n vector<int> findAnagrams(string s, string p) {\n int n = s.size(); \n int m = p.size(); \n\n vector<int> hash(26); \n for (auto ch: p) {\n hash[ch - 'a']++; \n }\n\n int dp[26][n]; \n memset(dp, 0, sizeof(dp));... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int>result;\n vector<int>v(26,0);\n int ssize=s.length();\n int psize=p.length();\n for(int i=0;i<psize;i++)\n {\n v[p[i]-'a']++;\n }\n for(int i=0;i<ssi... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\n\npublic:\nvector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n\n vector<int> count(26, 0);\n\n for(char &c : p)\n count[c - 'a']++;\n\n for(int i = 0; i < s.length(); ++i) {\n vector<int> hash(26, 0);\n\n for(int j = i; j < i + p.length() &... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n\n vector<int> count(26, 0);\n\n for(char &c : p)\n count[c - 'a']++;\n\n for(int i = 0; i < s.length(); ++i) \n {\n vector<int> hash(26, 0);\n\n for(int j = i; j < i + p.le... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\nvector<int> findAnagrams(string s, string p) {\n vector<int> ans;\n\n vector<int> count(26, 0);\n\n for(char &c : p)\n count[c - 'a']++;\n\n for(int i = 0; i < s.length(); ++i) {\n vector<int> hash(26, 0);\n\n for(int j = i; j < i + p.length() && ... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n int n1=s.size();\n int n2=p.size();\n vector<int>ans;\n vector<int>hash(26,0);\n for(char &c:p){\n hash[c-'a']++;\n }\n for(int i=0;i<n1;i++){\n vector<int>... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n std::vector<int> findAnagrams(std::string s, std::string p) {\n std::unordered_map<char, std::pair<int, int>> um;\n for (auto &c : p) {\n um[c] = {um[c].second+1, um[c].second+1};\n }\n \n std::vector<int> res;\n std::queue... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int> a(26);\n for(char i : p) a[i - 'a']++;\n vector<vector<int>> tab(s.size() + 1, vector<int>(26));\n vector<int> ans;\n for(int i = 0; i < s.size(); i++){\n tab[i + 1] = t... |
438 | <p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>'s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d... | 3 | {
"code": "class Solution {\npublic:\nvector<int> findAnagrams(string s, string p) \n{\n int i=0,n=s.size(),m=p.size(),j;\n vector<int> c(26,0),ans,mc(26,0);\n if (n<m)\n {\n return ans;\n }\n vector<vector<int>> mps(n,vector<int>(26,0));\n while (i<m)\n {\n c[p[i]-'a']++;\n ... |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 0 | {
"code": "class Solution {\npublic:\n\n bool check(long long int x,int n){\n long long int tot=x*(x+1)/2;\n return tot<=n;\n }\n int arrangeCoins(int n) {\n int l=1,h=n;\n while(l<=h){\n long long int mid=l+(h-l)/2;\n if(check(mid,n)){\n l=mid+1... |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 0 | {
"code": "class Solution {\npublic:\n int arrangeCoins(int n) \n {\n int rem=n;\n for(int i=1;i<n;i++)\n {\n if(rem<i)\n return i-1;\n else if(rem==i)\n return i;\n rem-=i;\n }\n return rem;\n }\n};",
"memory... |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 0 | {
"code": "class Solution {\npublic:\n int arrangeCoins(int n) {\n int j = 1;\n long long i = 0;\n while(i+j <= n){\n i+=j;\n j++; \n }\n return j-1;\n }\n};",
"memory": "8300"
} |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 0 | {
"code": "class Solution {\npublic:\n int arrangeCoins(int n) {\n // (1 + p) * p / 2 <= n. Find p\n // 0.5p^2 + 0.5p - n <= 0\n // p = -0.5 +- sqrt(0.25 + 2n) / 1\n // p = sqrt(0.25 + 2n) - 0.5\n // p = sqrt(2)sqrt(0.125 + n) - 0.5\n return int(sqrt(2) * sqrt(0.125 + n) -... |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 0 | {
"code": "class Solution {\npublic:\n int arrangeCoins(int n) {\n int i = 1;\n while(n>0)\n {\n n -= i;\n if(n<0)\n {\n return i-1;\n }\n if(n == 0)\n {\n return i;\n }\n i++;... |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 0 | {
"code": "class Solution {\npublic:\n int arrangeCoins(int n) {\n return (-1+sqrt(1 + (8*(double)n)))/2;\n }\n};",
"memory": "8500"
} |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 0 | {
"code": "class Solution {\npublic:\n int arrangeCoins(int n) {\n long long total = 0;\n for (long long i = 1; ; i++){\n total += i;\n if (total > n) return i - 1;\n else if (total == n) return i;\n }\n }\n};",
"memory": "8500"
} |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 1 | {
"code": "class Solution {\npublic:\n int arrangeCoins(int n) {\n int s = 1, e = n;\n long long int m = (e-s)/2 + s;\n long long int a = 1;\n while(s <= e){\n long long int b = ((m*m)+m) / 2;\n if(b <= n){\n a = max(a,m);\n s = m + 1;... |
441 | <p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
<p>Given the integer <code>n</code>, retur... | 1 | {
"code": "class Solution {\npublic:\n int arrangeCoins(int n) {\n int s = 1, e = n;\n long long int m = (e-s)/2 + s;\n long long int a = 1;\n while(s <= e){\n long long int b = ((m*m)+m) / 2;\n if(b <= n){\n a = max(a,m);\n s = m + 1;... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 0 | {
"code": "class Solution {\npublic:\n // 02/09/24\n vector<int> findDuplicates(vector<int>& nums) {\n vector<int> out;\n out.reserve(nums.size()/2);\n for (int i = 0; i < nums.size(); ++i) {\n int index = abs(nums[i]) - 1; // 1 to n -> 0 to n-1\n if (nums[index] < 0) ... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 0 | {
"code": "static const auto x = []() {\n\tstd::ios::sync_with_stdio(false);\n\tstd::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return 0;\n}();\nclass Solution {\npublic:\n // 02/09/24\n vector<int> findDuplicates(vector<int>& nums) {\n vector<int> out;\n out.reserve(nums.size()/2);\n ... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 0 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& nums) {\n std::ios::sync_with_stdio(false);\n std::cin.tie(0);\n int n = nums.size();\n vector<int> ans;\n for(int i = 0; i < n; i++)\n {\n int x = abs(nums[i]);\n if(nums[... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 0 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& nums) {\n vector<int>ans;\n int n= nums.size();\n \n for(int i=0; i<n ; i++){\n int index= abs(nums[i])-1;\n\n if(nums[index]<0){\n ans.push_back(abs(nums[i]));\n }\n else{\n ... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 0 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& nums) {\n vector<int> res;\n int n=nums.size();\n for(int i=0;i<n;i++){\n int ind=abs(nums[i])-1;\n if(nums[ind]>0){\n nums[ind]=-1*nums[ind];\n }\n else{\n... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 0 | {
"code": "class Solution {\n// What if we are asked to solve this without space, also in O(n) time. Can we do that?\n\n// Think in terms of on and off. Turning on and turning off a switch. If a switch is already turned on, you can not turn it on again.\n\n// Given this: [2,5,2,1,1,4]\n\n// Go to index 0 and flip... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 1 | {
"code": "class Solution { \npublic: \n vector<int> findDuplicates(vector<int>& nums) { \n int n=nums.size(); \n vector<int>duplicate(n); \n int a=0; \n for(int i=0;i<n;i++) \n { \n for(int j=i+1;j<n;j++) \n { \n if(nums[i]==nums[j]) \n { \n ... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 1 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int c=0;\n for(int i=0;i<nums.size()-1;i++){\n if(nums[i]==nums[i+1]){\n c++;\n }\n }\n vector<int>arr(c);\n int k... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 1 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& nums) {\n int n=nums.size();\n vector<int>v;\n sort(nums.begin(),nums.end());\n for(int i=1;i<n;i++)\n {\n if(nums[i]==nums[i-1])\n {\n v.push_back(nums[i]);\n ... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 1 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& nums) {\n sort(nums.begin() , nums.end());\n vector<int>ans ;\n int temp = nums[0];\n // chekcing \n for (int i = 1 ; i< nums.size() ; i++){\n if(temp == nums[i]){\n ans.push_... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& arr) {\n vector<int> ans;\n int size = arr.size();\n sort(arr.begin(), arr.end());\n int i = 0;\n while(i<size){\n int count = 1;\n for(int j = i+1;j<size;j++){\n ... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& nums) {\n vector<int> ans;\n vector<int> temp(nums.size()+1);\n for(int i=0;i<nums.size();i++){\n temp[nums[i]]+=1;\n if(temp[nums[i]]>=2){\n ans.push_back(nums[i]);\n ... |
442 | <p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
<p>You mu... | 2 | {
"code": "class Solution {\npublic:\n vector<int> findDuplicates(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int n = nums.size();\n vector<int>ans;\n for(int i=0;i<n-1;i++){\n if(nums[i]==nums[i+1]) ans.push_back(nums[i]);\n }\n return ans;\n }\n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.