id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
206 | <p>Given the <code>head</code> of a singly linked list, reverse the list, and return <em>the reversed list</em>.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg" style="width: 542px; height: 222px;" />
<pre>
<strong>Input:... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
206 | <p>Given the <code>head</code> of a singly linked list, reverse the list, and return <em>the reversed list</em>.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg" style="width: 542px; height: 222px;" />
<pre>
<strong>Input:... | 2 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
206 | <p>Given the <code>head</code> of a singly linked list, reverse the list, and return <em>the reversed list</em>.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg" style="width: 542px; height: 222px;" />
<pre>
<strong>Input:... | 2 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
206 | <p>Given the <code>head</code> of a singly linked list, reverse the list, and return <em>the reversed list</em>.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg" style="width: 542px; height: 222px;" />
<pre>
<strong>Input:... | 3 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
206 | <p>Given the <code>head</code> of a singly linked list, reverse the list, and return <em>the reversed list</em>.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg" style="width: 542px; height: 222px;" />
<pre>
<strong>Input:... | 3 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "/*class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n for(int i=0; i<nums.size(); i++)\n for(int j=i+1; j<nums.size(); j++)\n if(nums[i]+nums[j] == target)\n return vector<int>({i,j});\n return {-1};\n }\n};*/\n/... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "/*class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n for(int i=0; i<nums.size(); i++)\n for(int j=i+1; j<nums.size(); j++)\n if(nums[i]+nums[j] == target)\n return vector<int>({i,j});\n return {-1};\n }\n};*/\n/... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "#pragma GCC optimize(\"Ofast\")\n\nstatic const int __ = []()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n return 0;\n}();\n\n\nint init = [] {\n \n ofstream out(\"user.out\");\n cout.rdbuf(out.rdbuf());\n std::string first;\n std::string sec;... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "#pragma GCC optimize(\"Ofast\")\n\nstatic const int __ = []()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n return 0;\n}();\n\n\nint init = [] {\n \n ofstream out(\"user.out\");\n cout.rdbuf(out.rdbuf());\n std::string first;\n std::string sec;... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> v;\n for(int i=0;i<nums.size();i++){\n for(int j=i+1;j<nums.size();j++){\n if(nums[i]+nums[j]==target){\n v.push_back(i);\n v.push_b... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int n = nums.size();\n for(int i = 0; i<n-1; i++){\n for(int j = i+1; j<n; j++){\n if(nums[i] + nums[j] == target){\n return {i , j};\n }\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n for(int i=0;i<nums.size();i++){\n for(int j=i+1;j<nums.size();j++){\n if(nums[i]+nums[j]==target){\n return {i,j};\n }\n }\n }\nreturn {0};\n }\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) \n {\n int n=nums.size();\n for(int i=0;i<n-1;i++)\n {\n for(int j=i + 1;j<n;j++){\n if(nums[i]+nums[j]==target){\n return {i,j};\n }\n\n }\n }\nreturn{};\n }\n};",
"memory": "126... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int n = nums.size();\n for(int i=0;i<n-1;i++){\n for(int j=i+1;j<n;j++){\n if(nums[i]+nums[j]==target){\n return {i,j};\n }\n }\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n\n int sum = 0;\n int n = nums.size();\n\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]==target)\n {\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n for(int i=0;i<nums.size();i++){\n for(int j=i+1;j<nums.size();j++){\n if(nums[i]+nums[j]==target){\n return {i,j};\n }\n }\n }\n r... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> result;\n for (int i = 0; i < nums.size(); i++){\n for (int j = 0; j<nums.size(); j++){\n if (nums[i] + nums[j] == target && i != j){\n result.push_bac... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int n= nums.size();\n for(int i=0;i<n-1;i++){\n for(int j=i+1;j<n;j++){\n if(nums[i]+nums[j]==target){\n return{i,j};\n }\n }\n }\... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 0 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int n = nums.size();\n for (int i=0; i<n; i++) {\n for (int j=i+1; j<n; j++) {\n if (nums[i]+nums[j] == target) {\n return {i, j};\n }\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> result {0,0};\n \n for(int i=0;i<nums.size();i++)\n {\n for(int j = i+1; j< nums.size();j++)\n {\n if (nums[i]+nums[j]==target)\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int n = nums.size();\n for (int i = 0; i < n-1;i++){\n for (int j =i+1; j <n ; j++){\n if (nums[i] + nums[j] == target){\n return {i,j};\n }\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int n = (int)nums.size(); \n for(int i = 0; i < n; i++) {\n for (int j = i+1; j < n; j++) {\n if (nums[i] + nums[j] == target) {\n printf(\"[%d, %d]\", i, j);\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n for(int i=0; i<nums.size(); i++){\n for(int j = i+1; j<nums.size(); j++){\n if(nums[i]+nums[j]==target){\n return {i, j};\n }\n }\n }\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int>temp=nums;\n sort(temp.begin(),temp.end());\n int i=0;\n int j=nums.size()-1;\n int n1,n2;\n while(i<j)\n {\n if(temp[i]+temp[j]==target){\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int n=nums.size();\n vector<int> ans(n,0);\n for(int i=0;i<n-1;i++){\n for(int j=i+1;j<n;j++){\n if(nums[i]+nums[j]==target){\n ans= {i,j};\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> nums2 = nums;\n sort(nums2.begin(),nums2.end());\n int left = 0;\n int rigth = nums.size()-1;\n int sum = nums2[left] + nums2[rigth];\n while (sum != target) {\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int j = nums.size() - 1;\n int i = 0;\n int n1,n2;\n vector<int> ans, store;\n store=nums;\n sort(store.begin(),store.end());\n\n while (i < j) {\n if (store[i] +... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "// #include <map>\nclass Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> ans;\n int n=nums.size();\n int l=0;\n int h=n-1;\n vector<int> temp=nums;\n int i=0;\n int j=0;\n sort(temp.begin(),temp.end());\n while... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> res=nums;\n sort(nums.begin(),nums.end());\n vector<int> ans;\n int i=0;\n int j=nums.size()-1;\n int cur_sum;\n int a,b;\n while(i<j)\n {\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> nums2 = nums;\n sort(nums2.begin(),nums2.end());\n int left = 0;\n int rigth = nums.size()-1;\n int sum = nums2[left] + nums2[rigth];\n while (sum != target) {\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int l = 0;\n int r = nums.size()-1;\n vector<pair<int,int>> p(r+1,pair<int,int>{0,0}) ;\n for(int i = 0;i<=r;i++){\n p[i].first = nums[i];\n p[i].second = i;\n }\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> res;\n int sz = nums.size();\n vector<pair<int,int>> tmp(sz);\n for(int i = 0; i < sz; i++)\n {\n tmp[i].first = nums[i];\n tmp[i].second = i;\n }... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 1 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n struct ElemWithIndex {\n int num;\n int index;\n };\n\n std::vector<ElemWithIndex> elems(nums.size());\n for(int i = 0; i < static_cast<int>(nums.size()); i++) {\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 2 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) \n {\n // vector <int> ans;\n unordered_map <int,int> hash;\n for(int i =0;i<nums.size();i++)\n {\n int remaining = target - nums[i];\n if(hash.find(remaining)!=hash.end())\... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 2 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n unordered_map<int,int> ump;\n int n = nums.size();\n for(int i=0 ; i<n ; i++){\n int one = nums[i];\n int two = target - one;\n\n if(ump.find(two)!=ump.end()){\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 2 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int t) {\n int n=nums.size();\n unordered_map<int,int>m;\n for(int i=0;i<n;i++){\n if(m.find(t-nums[i])!=m.end()){\n return {i,m[t-nums[i]]};\n }\n m[nums[i]]=i;\n }\n return {... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 2 | {
"code": "class Solution {\n public:\n vector<int> twoSum(vector<int>& nums, int target) {\n unordered_map<int, int> numToIndex;\n\n for (int i = 0; i < nums.size(); ++i) {\n if (const auto it = numToIndex.find(target - nums[i]);\n it != numToIndex.cend())\n return {it->second, i};\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 2 | {
"code": "class Solution \n{\npublic:\n\n vector<int> twoSum(vector<int>& nums, int target) \n {\n unordered_map<int, int> hashmap;\n auto size = nums.size();\n for (int i = 0; i < size; ++i)\n {\n if (hashmap.count(target - nums[i]) > 0)\n {\n r... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 2 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n unordered_map<int, int> numMap;\n int n = nums.size();\n for(int i = 0; i < n; i++){\n int complement = target - nums[i];\n if(numMap.count(complement)){\n return {... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 2 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n \n unordered_map<int,int>hashtable;\n for (int i =0;i< nums.size();++i){\n int compliment = target - nums[i];\n if(hashtable.find(compliment) !=hashtable.end()){\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 2 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n\n int need;\n unordered_map<int,int>m;\n int n=nums.size();\n for(int i=0;i<n;i++)\n {\n need=target-nums[i];\n if(m.find(need)!=m.end())\n {\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n std::unordered_map<int, int> num_to_index;\n for (int i = 0; i < nums.size(); ++i) {\n int num = nums[i];\n int complement = target - num;\n if (num_to_index.find(complement) ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n map <int, int> mp;\n for(int i=0;i<nums.size(); i++){\n int val = nums[i];\n int more = target - val;\n if(mp.find(more) != mp.end()) {\n return {mp[more], i};\... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "#include <vector>\r\n#include <map>\r\nusing namespace std;\r\nclass Solution {\r\npublic:\r\n vector<int> twoSum(vector<int>& nums, int target) {\r\n map<int, int> hash;\r\n for (int i = 0; i < nums.size(); i++) {\r\n if(hash.find(target - nums[i]) != hash.end()) {\r\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "// #include <vector>\r\n// #include <map>\r\n// using namespace std;\r\nclass Solution {\r\npublic:\r\n vector<int> twoSum(vector<int>& nums, int target) {\r\n map<int, int> hash;\r\n for (int i = 0; i < nums.size(); i++) {\r\n if(hash.find(target - nums[i]) != hash.end()) {\r\n... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> ans;\n map<int, int> d;\n for (int i = 0; i < nums.size(); i++) {\n int t = target - nums[i];\n if (d.find(t) != d.end()) {\n ans.push_back(d[t]);\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n int n=nums.size();\n vector<int> res;\n // for(int i=0;i<a;i++){\n // for(int j=i+1;j<a;j++){\n // if(nums[i]+nums[j]==target){\n // res.push_back(i);\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int>a;\n map<int,int>mp;\n for(int i=0;i<nums.size();i++){\n if(mp.find(target-nums[i])==mp.end()){\n mp[nums[i]]=i;\n }\n else{\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> vec;\n map<int,int> mpp;\n for(int i = 0 ;i<nums.size() ;i++){\n int compliment = target - nums[i];\n if(mpp.find(compliment) != mpp.end()){\n vec.push_... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": " bool comp(const pair<int,int>& a,const pair<int,int>& b){\n // if(a.second == b.second){\n // return a.first < b.first;\n // }\n return a.second < b.second;\n }\nclass Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<pair<int... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n \n // Create hashmap of (nlog(n))\n unordered_map<int, vector<int>> numIndices;\n\n for (int numIdx = 0; numIdx < nums.size(); ++numIdx) {\n int num = nums.at(numIdx);\n\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n std::map<int, int> numMap; // key:value, index\n\n for (int i = 0; i < nums.size(); i++)\n {\n if (numMap.count(nums[i])) \n {\n numMap.erase(nums[i]);\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n struct inty{\n int a=-1;\n };\n vector<int> twoSum(vector<int>& num, int t) {\n unordered_map<int,inty> mp;\n vector<int> ans;\n int n=num.size();\n\n for(int i=0; i<=n-1; i++){\n if(mp[num[i]].a==-1) mp[num[i]].a=i;\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n std::map<int, int> n;\n\n for(int i = 0; i < nums.size(); ++i){\n n.insert({nums[i], i});\n }\n \n for(int i = 0; i < nums.size(); ++i){\n int rest = std::abs(target - n... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n struct inty{\n int a=-1;\n };\n vector<int> twoSum(vector<int>& num, int t) {\n unordered_map<int,inty> mp;\n int n=num.size();\n\n for(int i=0; i<=n-1; i++){\n if(mp[num[i]].a==-1) mp[num[i]].a=i;\n if(mp[t-num[i]].a>-1... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n multimap<int, int> mp;\n for (int i = 0; i < nums.size(); i++) {\n mp.insert({nums[i], i});\n }\n for (int i = 0; i < nums.size(); i++) {\n int complement = target - nums[i... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int> &nums, int target)\n{\n unordered_map<int, int> mp;\n for (int i{}; i < nums.size(); ++i)\n {\n if (mp[target - nums[i]])\n {\n int ind = find(nums.begin(), nums.begin() + i, target - nums[i]) - nums.begin();\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n unordered_map<int, int> m;\n for(int i = 0; i < nums.size(); i++) {\n int v = nums[i];\n if(m[v]) return {i,m[v]-1};\n m[target-v] = i+1;\n }\n\n return {};\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n struct inty{\n int a=-1;\n };\n vector<int> twoSum(vector<int>& num, int t) {\n unordered_map<int,inty> mp;\n vector<int> ans;\n int n=num.size();\n\n for(int i=0; i<=n-1; i++){\n if(mp[num[i]].a==-1) mp[num[i]].a=i;\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n map<int, int> m;\n int n = nums.size();\n for (int i = 0; i < n; i++) {\n if (m[target - nums[i]] > 0) {\n return {i, m[target - nums[i]]-1};\n }\n else {\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n unordered_map<int, int> indices;\n\n for (int i = 0; i < nums.size(); i++) {\n int num = nums[i];\n if (indices[num]) return { i, indices[num] - 10 };\n\n indices[target - num... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n \n vector<int> index;\n std::unordered_map<int, int> hTable;\n for(unsigned int i{0}; i < nums.size(); ++i){\n\n int curNum = nums[i];\n auto it = hTable.find(curNum);\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n unordered_map <int,int> map;\n for(int i=0;i<nums.size();i++){\n map[nums[i]]=i;\n }\n for(int i=0;i<nums.size();i++){\n int diff=target-nums[i];\n if(map.find(d... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> ans;\n unordered_map<int, int> myMap;\n for(int i = 0; i < nums.size(); i++) {\n if (myMap.count(nums[i]) == 0) {\n myMap[target - nums[i]] = i;\n }\n ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\n\npublic:\n\n vector<int> twoSum(vector<int> &nums, int target) {\n\n unordered_map<int, int> hash;\n\n for (int i = 0; i < nums.size(); i++) {\n\n hash[nums[i]] = i;\n\n }\n\n for (int i = 0; i < nums.size(); i++) {\n\n int complement ... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n \n unordered_map<int, int> numMap; \n int n = nums.size(); // size of array\n\n // Build the hash table\n for (int i = 0; i < n; i++) {\n numMap[nums[i]] = i; // map: nu... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n unordered_map<int,int> hash; \n for (int i = 0; i < nums.size();i++){\n hash[nums[i]] = i;\n }\n\n for (int j = 0; j < nums.size(); j++){\n int complement = target - nums[j... |
1 | <p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> elemen... | 3 | {
"code": "class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n vector<int> result;\n unordered_map<int, int> m;\n m[nums[0]] = 0;\n\n for (int i = 1; i < nums.size(); i++) {\n if (m.find(target - nums[i]) != m.end()) {\n result.pus... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "#include <filesystem>\n#include <iostream>\n#include <string>\n#include <fstream>\n\n// struct ListNode {\n// int val;\n// ListNode *next;\n// ListNode()\n// : val(0)\n// , next(nullptr) {}\n// ListNode(int x)\n// : val(x)\n// , next(nullptr) {}\n// ... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\ninline bool isDigit(const c... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "inline bool isDigit(const char c) {\n return (c >= '0') && (c <= '9');\n}\nvoid parse_and_solve(const std::string& s1, const std::string& s2, std::ofstream& out) {\n const int S1 = s1.size();\n const int S2 = s2.size();\n if (S1 < S2) {\n parse_and_solve(s2, s1, out);\n return;\n ... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\ninline bool isDigit(const c... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\ninline bool isDigit(const c... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\ninline bool isDigit(const c... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\ninline bool isDigit(const c... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "//Optimized\nstatic const bool Booster = [](){\n std::ios_base::sync_with_stdio(false);\n std::cout.tie(nullptr);\n std::cin.tie(nullptr);\n return true;\n}();\n\ninline bool isDigit(const char c) {\n return (c >= '0') && (c <= '9');\n}\n\nvoid parse_and_solve(const std::string& s1, const st... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "#include<iostream>\nusing namespace std;\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next)... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 0 | {
"code": "class Solution {\n public:\n ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {\n ListNode dummy(0);\n ListNode* curr = &dummy;\n int carry = 0;\n\n while (l1 != nullptr || l2 != nullptr || carry > 0) {\n if (l1 != nullptr) {\n carry += l1->val;\n l1 = l1->next;\n }\... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 2 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
2 | <p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
<p>You may assume the two numbers do not conta... | 2 | {
"code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... |
4 | <p>Given two sorted arrays <code>nums1</code> and <code>nums2</code> of size <code>m</code> and <code>n</code> respectively, return <strong>the median</strong> of the two sorted arrays.</p>
<p>The overall run time complexity should be <code>O(log (m+n))</code>.</p>
<p> </p>
<p><strong class="example">Example 1:<... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n\nstatic const bool Booster = [](){\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return true;\n}();\n\nvoid parse_input_and_solve(std::ofstream& out, s... |
4 | <p>Given two sorted arrays <code>nums1</code> and <code>nums2</code> of size <code>m</code> and <code>n</code> respectively, return <strong>the median</strong> of the two sorted arrays.</p>
<p>The overall run time complexity should be <code>O(log (m+n))</code>.</p>
<p> </p>
<p><strong class="example">Example 1:<... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n\nstatic const bool Booster = [](){\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return true;\n}();\n\nvoid parse_input_and_solve(std::ofstream& out, s... |
4 | <p>Given two sorted arrays <code>nums1</code> and <code>nums2</code> of size <code>m</code> and <code>n</code> respectively, return <strong>the median</strong> of the two sorted arrays.</p>
<p>The overall run time complexity should be <code>O(log (m+n))</code>.</p>
<p> </p>
<p><strong class="example">Example 1:<... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n\nstatic const bool Booster = [](){\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return true;\n}();\n\nvoid parse_input_and_solve(std::ofstream& out, s... |
4 | <p>Given two sorted arrays <code>nums1</code> and <code>nums2</code> of size <code>m</code> and <code>n</code> respectively, return <strong>the median</strong> of the two sorted arrays.</p>
<p>The overall run time complexity should be <code>O(log (m+n))</code>.</p>
<p> </p>
<p><strong class="example">Example 1:<... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\n\nstatic const bool Booster = [](){\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n return true;\n}();\n\nvoid parse_input_and_solve(std::ofstream& out, s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.