id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 0 | {
"code": "class Solution {\npublic:\n static bool compare(const string& a, const string& b) {\n const auto len1 = a.length(), len2 = b.length(), mx = lcm(len1, len2);\n for (size_t i = 0; i < mx; i++)\n if (const char c1 = a[i % len1], c2 = b[i % len2]; c1 != c2)\n return c... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 0 | {
"code": "bool compare(int a,int b)\n{\n return to_string(a)+to_string(b)>to_string(b)+to_string(a);\n}\nclass Solution {\npublic:\n string largestNumber(vector<int>& arr) {\n sort(arr.begin(),arr.end(),compare);\n string ans = \"\";\n for(int i = 0;i<arr.size();i++)\n ans+=to_strin... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 0 | {
"code": "class Solution {\npublic:\n // bool compare(int &a,int &b)\n // {\n // string aa=to_string(a);\n // string bb=to_string(b);\n // return (aa+bb)>(bb+aa);\n // };\n string largestNumber(vector<int>& nums) {\n\n auto compare=[](int &a,int &b)\n {\n str... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 0 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n sort(nums.begin(), nums.end(), [](int const& x, int const& y) {\n string sx = to_string(x);\n string sy = to_string(y);\n return (sx+sy > sy+sx);\n });\n string s;\n if (n... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 0 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n sort(nums.begin(), nums.end(), [](int const& x, int const& y) {\n string sx = to_string(x);\n string sy = to_string(y);\n return (sx+sy > sy+sx);\n });\n string s;\n bool ... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 0 | {
"code": "class Solution {\npublic:\n bool static compare(int num1,int num2){\n string str1=to_string(num1);\n string str2=to_string(num2);\n return str1+str2>str2+str1;\n }\n string largestNumber(vector<int>& nums) {\n sort(nums.begin(),nums.end(),compare);\n string ans=\... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n bool static check(int a, int b) {\n string s1 = to_string(a);\n string s2 = to_string(b);\n\n return s2 + s1 < s1 + s2;\n }\n\n string largestNumber(vector<int>& nums) {\n string ans;\n sort(nums.begin(), nums.end(), check);\n\n\n ... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\n \n\npublic:\n string largestNumber(vector<int>& nums) {\n string ans = \"\";\n\n auto cmp = [](int& x, int& y) {\n string s = to_string(x) + to_string(y);\n string t = to_string(y) + to_string(x);\n return s > t;\n };\n s... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n std::sort(nums.begin(), nums.end(), [](int a, int b) {\n return std::to_string(a) + std::to_string(b) > std::to_string(b) + std::to_string(a);\n });\n \n if (nums[0] == 0) {\n return... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n vector<string>num;\n for(int i=0;i<nums.size();i++){\n num.push_back(to_string(nums[i]));\n }\n for(int i=0;i<num.size()-1;i++){\n for(int j=0;j<num.size()-1;j++){\n s... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) \n {\n vector<string> str;\n for(int i = 0; i < nums.size(); i++)\n {\n str.push_back(to_string(nums[i]));\n }\n for(int i = 0; i < nums.size() - 1; i++)\n {\n for(int j... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n bool compare(string& s1, string& s2){\n return s1+s2 > s2+s1;\n }\n\n string largestNumber(vector<int>& nums) {\n list<string> ordered;\n for(int n : nums){\n string s = to_string(n);\n auto it = ordered.begin();\n w... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n std::sort(nums.begin(), nums.end(), [](int a, int b) {\n return std::to_string(a) + std::to_string(b) > std::to_string(b) + std::to_string(a);\n });\n \n if (nums[0] == 0) {\n return... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n bool static comp(int &nums1, int &nums2) {\n string s1;\n string s2;\n s1 = to_string(nums1) + to_string(nums2);\n s2 = to_string(nums2) + to_string(nums1);\n return s1>s2;\n }\n string largestNumber(vector<int>& nums) {\n sort(... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n sort(begin(nums), end(nums), [](auto &a, auto &b) {\n string aa = std::to_string(a);\n string bb = std::to_string(b);\n return aa + bb > bb + aa;\n });\n string ans = std::accumu... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n int compare(long long a, long long b) {\n string s1 = to_string(a);\n string s2 = to_string(b);\n string temp1 = s1 + s2;\n string temp2 = s2 + s1;\n int x=0;\n while(x<temp1.length() && x<temp2.length()) {\n if(temp1[x]>te... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n bool compare(long long a, long long b) {\n string s1 = to_string(a);\n string s2 = to_string(b);\n string temp1 = s1 + s2;\n string temp2 = s2 + s1;\n int x=0;\n while(x<temp1.length() && x<temp2.length()) {\n if(temp1[x]>t... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n\n int n = nums.size();\n vector<string>str(n);\n string result = \"\";\n\n //convert nums from int to string\n for(int i = 0; i < n; i++){\n str[i] = to_string(nums[i]);\n }\n\n ... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n std::sort(nums.begin(), nums.end(), [](int a, int b) {\n return std::to_string(a) + std::to_string(b) > std::to_string(b) + std::to_string(a);\n });\n \n if (nums[0] == 0) {\n return... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n std::ranges::sort(nums,\n [](const std::string& x, const std::string& y) {\n return x + y > y + x;\n },\n [](const int x) {\n return std::to_string(x);\n });\n if (nums... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n vector<string>v;\n for(int i:nums){\n v.push_back(to_string(i));\n }\n sort(v.begin(),v.end(),[](string &s1,string &s2){return s1+s2>s2+s1;});\n \n string res;\n for(string s:... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 1 | {
"code": "class Solution {\npublic:\n\n static bool mycomp(string a , string b){\n string t1 = a+b;\n string t2 = b+a;\n return t1 > t2 ;\n }\n string largestNumber(vector<int>& nums) {\n\n vector<string> arr;\n\n for(auto& it: nums){\n arr.push_back(to_string(i... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 2 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n vector<string> strNums;\n for (int num : nums) {\n strNums.push_back(to_string(num));\n }\n\n \n sort(strNums.begin(), strNums.end(), [](string &a, string &b) {\n return a + b >... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 2 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n vector<string> str;\n for (auto x : nums) {\n str.push_back(to_string(x));\n }\n sort(str.begin(), str.end(), [](string &s1, string &s2){ return s1 + s2 > s2 + s1;});\n string ans;\n ... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 2 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n vector<string> nums2;\n\n for(int n : nums){\n nums2.push_back(to_string(n));\n }\n\n sort(nums2.begin(),nums2.end(), [](string &a, string &b) {\n return a + b > b + a;\n });\... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 2 | {
"code": "class Solution {\npublic:\n\n static bool mycomp(string a, string b){\n return a+b > b+a;\n }\n\n string largestNumber(vector<int>& nums) {\n vector<string> nums2;\n\n for(int n : nums){\n nums2.push_back(to_string(n));\n }\n\n sort(nums2.begin(),nums2... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 3 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n vector<string> nums2;\n\n for(int n : nums){\n nums2.push_back(to_string(n));\n cout<<n<<endl;\n }\n cout<<endl;\n\n sort(nums2.begin(),nums2.end(), [](string &a, string &b) {... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 3 | {
"code": "class Solution {\npublic:\n static bool mycomp(string a, string b){\n string t1 = a+b;\n string t2 = b+a;\n return t1>t2;\n }\n string largestNumber(vector<int>& nums) {\n vector<string>snums;\n for(auto n:nums){\n snums.push_back(to_string(n));\n ... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 3 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) \n {\n string ans = \"\";\n vector<string>arr;\n\n for(int i = 0 ; i < nums.size() ; i++)\n arr.push_back(to_string(nums[i]));\n\n sort(arr.rbegin() , arr.rend() , [&](auto const &a , auto const &b ... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 3 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n\n std::vector<std::string> stringNums(nums.size());\n std::transform(nums.begin(), nums.end(),\n stringNums.begin(), \n [](int num) {\n return std::to_string(num);\n }\n ... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 3 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n\n std::vector<std::string> stringNums(nums.size());\n std::transform(nums.begin(), nums.end(),\n stringNums.begin(), \n [](int num) {\n return std::to_string(num);\n }\n ... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 3 | {
"code": "class Solution {\npublic:\n string largestNumber(vector<int>& nums) {\n vector<string> arr;\n for(auto i:nums){\n arr.push_back(to_string(i));\n }\n sort(arr.begin(), arr.end(), [=]( string &a, string &b){\n // tricky part\n return a+b > b+a;... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 3 | {
"code": "class Solution {\npublic:\n \n static bool cmp(string a,string b){\n return a+b>b+a;\n }\n\n string largestNumber(vector<int>& nums) {\n int n=nums.size();\n int sum=0;\n vector<string>v(n);\n for(int i=0;i<n;i++){\n v[i]=to_string(nums[i]);\n \n... |
179 | <p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>
<p>Since the result may be very large, so you need to return a string instead of an integer.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</st... | 3 | {
"code": "class Solution {\npublic:\n static std::string largestNumber(std::vector<int> &nums) {\n\n std::vector<std::string> stringNums;\n stringNums.reserve(nums.size());\n std::transform(nums.begin(), nums.end(), std::back_inserter(stringNums),\n [](int num) {\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n std::vector<std::string>\n findRepeatedDnaSequences(const std::string_view s) {\n if (s.size() < 10u)\n return {};\n\n // Store sequence of 10 symbols in single 64-bit number.\n // Each symbol uses 5 bits.\n\n // Prepare initial strin... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n\n /*inline int DNAInt(char l)\n {\n switch (l)\n {\n case 'A':\n return 0;\n case 'C':\n return 1;\n case 'G':\n return 2;\n case 'T':\n default:\n return 3;\n }\n }*/\n\... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n struct HashTrack\n {\n bool seen = false;\n bool repeat = false;\n };\n\n vector<string> findRepeatedDnaSequences(string s) {\n constexpr int NUMHASHES = 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4;\n constexpr int MASK = NUMHASHES - 1;\n\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n\n inline int DNAInt(char l)\n {\n switch (l)\n {\n case 'A':\n return 0;\n case 'C':\n return 1;\n case 'G':\n return 2;\n case 'T':\n default:\n return 3;\n }\n }\n\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n\n inline int DNAInt(char l)\n {\n switch (l)\n {\n case 'A':\n return 0;\n case 'C':\n return 1;\n case 'G':\n return 2;\n case 'T':\n default:\n return 3;\n }\n }\n\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n\n /*inline int DNAInt(char l)\n {\n switch (l)\n {\n case 'A':\n return 0;\n case 'C':\n return 1;\n case 'G':\n return 2;\n case 'T':\n default:\n return 3;\n }\n }*/\n\... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n\n /*inline int DNAInt(char l)\n {\n switch (l)\n {\n case 'A':\n return 0;\n case 'C':\n return 1;\n case 'G':\n return 2;\n case 'T':\n default:\n return 3;\n }\n }*/\n\... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<string>v;\n vector<string>v1;\n if(s.length()<10 || s.length()==10 || s.length()>5000){\n return v1;\n }\n\n string str;\n int flag=0;\n for(int i=0... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n vector<string>v;\n vector<string>v1;\n if(s.length()<10 || s.length()==10 || s.length()>5000){\n return v;\n }\n\n string str;\n int flag=0;\n for(int i=0;i<s.len... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n std::vector<std::string>\n findRepeatedDnaSequences(const std::string_view s) {\n if (s.size() < 10u)\n return {};\n\n // Store sequence of 10 symbols in single 64-bit number.\n // Each symbol uses 5 bits.\n\n // Prepare initial strin... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n std::vector<std::string>\n findRepeatedDnaSequences(const std::string_view s) {\n if (s.size() < 10u)\n return {};\n\n // Store sequence of 10 symbols in single 64-bit number.\n // Each symbol uses 5 bits.\n\n // Prepare initial strin... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n\tvector<size_t> indices(s.size());\n iota(indices.begin(), indices.end(), 0);\n sort(indices.begin(), indices.end(), [&s](size_t i0, size_t i1) {\n while (i0 < s.size() && i1 < s.size()) {\n if (s[i... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n\tvector<size_t> indices(s.size());\n iota(indices.begin(), indices.end(), 0);\n sort(indices.begin(), indices.end(), [&s](size_t i0, size_t i1) {\n for (;;) {\n if (i0 == s.size())\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n\tvector<size_t> indices(s.size());\n iota(indices.begin(), indices.end(), 0);\n sort(indices.begin(), indices.end(), [&s](size_t i0, size_t i1) {\n while (i0 < s.size() && i1 < s.size()) {\n if (s[i... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\n int hashVal(char c) {\n switch (c) {\n case 'A':\n return 0;\n case 'C':\n return 1;\n case 'G':\n return 1;\n case 'T':\n return 1;\n default:\n return 0;\n }\n }\n\npublic:\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\n int hashVal(char c) {\n switch (c) {\n case 'A':\n return 0;\n case 'C':\n return 1;\n case 'G':\n return 1;\n case 'T':\n return 1;\n default:\n return 0;\n }\n }\n\npublic:\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n int nucToInt (char c) {\n return c == 'G' ? 2 : c == 'T' ? 3 : c != 'A';\n }\n string intToDNA(int intDNA) {\n string res = \"\";\n int currNuc;\n while (res.size() < 10) {\n currNuc = intDNA % 4;\n res += currNuc == 3 ?... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n int power_four(int n){\n if (n == 0) {\n return 1;\n }\n int ans = 1;\n for (int i = 0; i < n; i++) {\n ans *= 4;\n }\n return ans;\n\n }\n\n string idx2string(int n) {\n string s = \"\";\n fo... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n static constexpr char bases[5] = \"ACGT\";\n int power_four(int n){\n if (n == 0) {\n return 1;\n }\n int ans = 1;\n for (int i = 0; i < n; i++) {\n ans *= 4;\n }\n return ans;\n\n }\n\n string idx2strin... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n static constexpr char bases[5] = \"ACGT\";\n int power_four(int n){\n if (n == 0) {\n return 1;\n }\n int ans = 1;\n for (int i = 0; i < n; i++) {\n ans *= 4;\n }\n return ans;\n\n }\n\n string idx2strin... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_map<int, int> freq; \n vector<string> res; \n int curr = 0; \n for(int i = 0; i < s.length(); i++) {\n curr <<= 2; \n curr &= ~(~0 << 20); \n switch(s[... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "// Solution1:\n// sliding window to get all 10 letters long substring + hashmap\n// Time: O(N*L), O(N) for the number of substring, O(L) for the comparation of the substring\n// Space: O(N*L)\n\n// Solution2: rabin-karp\n// ACGT=>0,1,2,3, calculate the corresponding number of the substring, sliding window ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n if (s.length() < 10) {\n return {}; // If the string is too short, return an empty vector\n }\n\n unordered_set<int> seen; // To store the encoded sequences\n unordered_set<string> ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\nvector<string> findRepeatedDnaSequences(string s) {\n if (s.size() < 10) return {}; // Early return if string is too short\n \n unordered_map<int, int> sequenceCount; // To store the 20-bit encoded sequences and their counts\n vector<string> result;\... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\nprivate:\n \npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n int k = 10 , n = s.size();\n vector<string> arr;\n if(n < k)\n return arr;\n \n unordered_map<int,int> charToInt;\n unordered_set<string> ans;\n u... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\nprivate:\n \npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<int> seen;\n unordered_set<int> dup;\n vector<string> result;\n vector<char> m(26);\n m['A' - 'A'] = 0;\n m['C' - 'A'] = 1;\n m['G' - 'A'] = 2;... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_map<int,int>mp; // hash value to count \n unordered_map<char,int>pair = {{'A', 0}, {'C', 1}, {'G', 2}, {'T', 3}};\n\n int hash_val = 0;\n int base = 4;\n int n = s.length();\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\n int getValue(char c) {\n int value;\n if(c=='A') value = 1;\n else if (c=='C') value = 2;\n else if (c=='G') value = 3;\n else value = 4;\n return value;\n }\n int calculateHash(string s, int start, int end) {\n i... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\n int base=5;\n int getValue(char c) {\n int value;\n if(c=='A') value = 1;\n else if (c=='C') value = 2;\n else if (c=='G') value = 3;\n else value = 4;\n return value;\n }\n int calculateHash(string s, int start, int ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n vector<string> res;\n int n=s.length();\n\n int label[n];\n for(int i=0;i<n;i++){\n if(s[i]=='A') label[i]=0; //00\n else if(s[i]=='C') label[i]=1; //01\n els... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "//rolling hash - rabin carp\n// class Solution {\n// public:\n// vector<string> findRepeatedDnaSequences(string s) {\n// if(s.length() <= 10) return {};\n// unordered_set<long long> uset;\n// vector<int> prime(26);\n// prime[0] = 1;\n// prime['C' - 'A'] = 2;\n// ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n int L = 10, n = s.size();\n if (n <= L) return vector<string>();\n\n // rolling hash parameters: base a\n int a = 4, aL = pow(a, L);\n\n // convert string to array of integers\n un... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<string> output;\n int L = 10;\n unordered_set<int> seen;\n if(s.length()<=10) return {};\n unordered_map<char,int> to_int = {{'A',1},{'C',2},{'G',3},{'T',4}};\n vecto... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n int L = 10, n = s.size();\n if (n <= L) return vector<string>();\n\n // rolling hash parameters: base a\n int a = 4, aL = pow(a, L);\n\n // convert string to array of integers\n un... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "#include <algorithm> // for find\n#include <cstddef> // for size_t\n#include <iterator> // for distance\n#include <string> // for basic_string, allocator, string, char_traits, hash\n#include <vector> // for vector\n\nclass Solution {\npublic:\n\tstd::vector<std::string> findRepeatedDnaSequences(st... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n std::vector<std::string>\n findRepeatedDnaSequences(const std::string_view s) {\n if(s.size() < 10)\n return {};\n\n std::unordered_map<uint64_t, uint32_t> sequences;\n\n uint64_t code=\n (uint64_t(s[0] - 'A') << 0u) |\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n std::vector<std::string>\n findRepeatedDnaSequences(const std::string_view s) {\n if(s.size() < 10)\n return {};\n\n std::unordered_map<uint64_t, uint32_t> sequences;\n\n uint64_t code=\n (uint64_t(s[0] - 'A') << 0u) |\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\n public:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<string> ans;\n unordered_set<string_view> seen;\n const string_view sv(s);\n\n for (int i = 0; i + 10 <= s.length(); ++i) {\n if (seen.contains(sv.substr(i, 10)))\n ans.insert(s.substr(... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\n public:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<string> ans;\n unordered_set<string_view> seen;\n const string_view sv(s);\n\n for (int i = 0; i + 10 <= s.length(); ++i) {\n if (seen.contains(sv.substr(i, 10)))\n ans.insert(s.substr(... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\n public:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<string> ans;\n unordered_set<string_view> seen;\n const string_view sv(s);\n\n for (int i = 0; i + 10 <= s.length(); ++i) {\n if (seen.contains(sv.substr(i, 10)))\n ans.insert(s.substr(... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\n public:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<string> ans;\n unordered_set<string_view> seen;\n const string_view sv(s);\n\n for (int i = 0; i + 10 <= s.length(); ++i) {\n if (seen.contains(sv.substr(i, 10)))\n ans.insert(s.substr(... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n if(s.length()<=10)\n return {};\n vector<string> subsets;\n vector<string> ans;\n for(int i=0;i<s.length()-9;i++)\n {\n string sub=s.substr(i,10);\n subsets.p... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution \n{\npublic:\n vector<string> findRepeatedDnaSequences(string s) \n {\n vector<string> strs;\n vector<string> dna;\n\n if(s.size() <= 10)\n return {};\n\n for(int i=s.size()-10; i>=0; i--)\n strs.push_back(string(s.begin()+i, s.begin()+... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution \n{\npublic:\n vector<string> findRepeatedDnaSequences(string s) \n {\n vector<string> strs;\n vector<string> dna;\n\n if(s.size() <= 10)\n return {};\n\n for(int i=s.size()-10; i>=0; i--)\n strs.push_back(string(s.begin()+i, s.begin()+... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution \n{\npublic:\n vector<string> findRepeatedDnaSequences(string s) \n {\n vector<string> strs;\n vector<string> dna;\n\n if(s.size() <= 10)\n return {};\n\n for(int i=s.size()-10; i>=0; i--)\n strs.push_back(string(s.begin()+i, s.begin()+... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n \n int L = 10;\n int str_length = s.length();\n vector<int> string_number;\n\n if(str_length < L) return vector<string>();\n\n int a = 4;\n int ha = pow(a, L);\n\n //... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<string> v, ans;\n v.reserve(size(s));\n ans.reserve(size(s));\n for(int i = 0; i < size(s); ++i) {\n string cur = s.substr(i, 10);\n if(v.count(cur)) {\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "\nsize_t encode(char letter) {\n switch (letter) {\n case 'A':\n return 0x0;\n case 'C':\n return 0x1;\n case 'G':\n return 0x2;\n case 'T':\n return 0x3;\n }\n return 0;\n}\n\n// TODO should maybe be string view\nvoid find_and_insert(size_t num, size_t index_start, const std::string &s,... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n long long bin_power_mod(long long base, long long power, long long mod){\n base%=mod;\n \n long long res = 1;\n\n while(power > 0){\n if(power & 1){\n res = res * base % mod;\n }\n base = base * base ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n // int findCount(const string& s, int low, int high, string& curr){\n // int ans = 0;\n // for(int i = low; i <= high; i++){\n // int j = 0;\n // int start = i;\n // while(j < curr.size() && start <= high && s[start] == curr[j]){... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n // int findCount(const string& s, int low, int high, string& curr){\n // int ans = 0;\n // for(int i = low; i <= high; i++){\n // int j = 0;\n // int start = i;\n // while(j < curr.size() && start <= high && s[start] == curr[j]){... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n const int p = 7, M = 1e9 + 9;\n vector<string> findRepeatedDnaSequences(string s) {\n long long n = s.size(), hash[n], p_pow[n];\n hash[0] = s[0] - 'A' + 1; p_pow[0] = 1;\n for (int i = 1; i < n; i++) {\n hash[i] = (hash[i - 1] * p % M + s[i... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n int n = s.size();\n unordered_set<string> hash;\n unordered_set<string> temp;\n for(int i = 0; i <= n-10; i++) {\n string str = s.substr(i, 10);\n if(hash.count(str) > 0) t... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution\n{\n public:\n std::vector<std::string> findRepeatedDnaSequences(const std::string& s)\n {\n std::unordered_set<std::string> seen, result;\n\n for(std::size_t i=0;i+10<=s.size(); ++i)\n {\n const auto current = s.substr(i,10);\n if(seen.con... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n //sliding window\n //cache each window\n\n //get a size 10 window\n //check if the window has been cached\n //if it has\n //add this to a return set\n //otherwise cache ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n vector<string> ans;\n if (s.size() < 10 ){\n return ans;\n }\n unordered_set<string> seq;\n unordered_set<string> inserted;\n for (int i = 0; i <= s.size() - 10; ++i){\n... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "#include <vector>\n#include <string>\n#include <unordered_set>\n\nclass Solution {\npublic:\n std::vector<std::string> findRepeatedDnaSequences(std::string s) {\n std::unordered_set<std::string> seen, repeated;\n std::vector<std::string> result;\n \n for (int i = 0; i + 9 < s... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n unordered_set<string>st;\n string temp=\"\";\n unordered_set<string>ans;\n vector<string>result;\n for(int i=0;i<s.length();i++){\n temp+=s[i];\n if(i>=9){\n ... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n if (s.size() < 10)\n return {};\n int i;\n int num=0;\n string s1;\n unordered_set<string> map1;\n unordered_set<string> map2;\n \n i=0;\n while (i<... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n if (s.size() < 10) {\n return {};\n }\n std::unordered_set<std::string> count;\n\n auto lhs = s.begin();\n auto rhs = s.begin() + 10;\n\n set<string> ret;\n while... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n if(s.size()<10)\n return {};\n unordered_set<string>st,as;\n vector<string>ans;\n \n for(int i=0;i<=s.size()-9;i++){\n string str=s.substr(i,10);\n if(st.find(st... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n vector<string> ans;\n set<string>mp;\n set<string>ansst;\n int r=9;\n int n=s.length();\n while(r<n)\n {\n string copy=s.substr(r-9,10);\n cout<<copy<<... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n set<string> ans;\n set<string> helper;\n\n for(int i=0;i<s.size();i++){\n string str=s.substr(i,10);\n if(helper.find(str) != helper.end()) ans.insert(str);\n helper.in... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n set<string> st;\n int n=s.length();\n string temp=\"\";\n for(int i=0;i<10;i++){\n temp=temp+s[i];\n }\n set<string> ans;\n st.insert(temp);\n for(int i=10... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n set<string> occurences;\n set<string> result;\n if(s.length() < 10) return {};\n\n string substring;\n for(int i = 9; i < s.length(); i++)\n { \n substring = s.substr(... |
187 | <p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>'A'</code>, <code>'C'</code>, <code>'G'</code>, and <code>'T'</code>.</p>
<ul>
<li>For example, <code>"ACGAATTCCG"</code> is a <strong>DNA sequence</strong>.</li>
</ul>
<p>When s... | 0 | {
"code": "class Solution {\npublic:\n vector<string> findRepeatedDnaSequences(string s) {\n set<string> st;\n set<string> ans;\n\n if(s.size() < 10) return {};\n \n for(int i = 0; i <= (s.size() - 10); i++) {\n string t = s.substr(i, 10);\n if(st.find(t) !=... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.