id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
2
{ "code": "class Solution {\npublic:\n int numberOfSequence(int n, vector<int>& sick) {\n const int MOD = 1e9 + 7; // Modulus value for operations\n\n // Initializing vectors and variables\n vector<int> xs; // Vector to store segment lengths without sick indices\n vector<bool> a(n, 0); ...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
2
{ "code": "class Solution {\npublic:\n int numberOfSequence(int n, vector<int>& sick) {\n int mod = 1e9+7;\n vector<int> xs;\n vector<bool> o(n, false);\n\n for (int i: sick) {\n o[i] = true;\n }\n\n for (int i = 0, count = 0; i < n; i++) {\n if (!o[i...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
2
{ "code": "class Solution {\npublic:\n\n const int mod = 1e9 + 7;\n\n vector<long long>fact;\n\n void pre(){\n fact.resize(1e5 + 1);\n\n fact[0] = 1;\n\n fact[1] = 1;\n\n for(int i = 2; i <= 1e5; i++) {\n fact[i] = fact[i - 1] * i;\n\n fact[i] %= mod;\n ...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
2
{ "code": "class Solution {\npublic:\n\n const int mod = 1e9 + 7;\n\n vector<long long>fact;\n\n void pre(){\n fact.resize(1e5 + 1);\n\n fact[0] = 1;\n\n fact[1] = 1;\n\n for(int i = 2; i <= 1e5; i++) {\n fact[i] = fact[i - 1] * i;\n\n fact[i] %= mod;\n ...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\npublic:\n\n const int mod = 1e9 + 7;\n\n vector<long long>fact;\n\n void pre(){\n fact.resize(1e5 + 1);\n\n fact[0] = 1;\n\n fact[1] = 1;\n\n for(int i = 2; i <= 1e5; i++) {\n fact[i] = fact[i - 1] * i;\n\n fact[i] %= mod;\n ...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\npublic:\n long long mod=1e9+7;\n long long binpow(int a,int b){\n if(b==0){\n return 1*1LL;\n }\n long long val=binpow(a,b/2);\n val%=mod;\n if(b&1){\n return (((val*val)%mod)*a)%mod;\n }\n return (val*val)%mod;\...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\npublic:\n int numberOfSequence(int n, vector<int>& sick) {\n long long mod = 1e9 + 7;\n vector<long long> factor(100005);\n vector<long long> powers(100005);\n factor[0] = 1;\n for (int i = 1; i <= n; i++) {\n factor[i] = factor[i - 1...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\npublic:\n const int MOD = 1e9 + 7;\n\n long long fast_pow(long long x, long long k) {\n long long ans = 1;\n while (k > 0) {\n if (k & 1) ans = (ans * x) % MOD;\n x = (x * x) % MOD;\n k >>= 1;\n }\n return ans;\n }\n\n ...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\npublic:\n const int MOD = 1e9 + 7;\n\n long long fast_pow(long long x, long long k) {\n long long ans = 1;\n while (k > 0) {\n if (k & 1) ans = (ans * x) % MOD;\n x = (x * x) % MOD;\n k >>= 1;\n }\n return ans;\n }\n\n ...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\npublic:\n int mod=1e9+7;\n long long solve(long long x, long long y){\n long long ans=1;\n while(y){\n if(y%2) ans=(ans*x)%mod;\n x=(x*x)%mod;\n y/=2;\n }\n return ans;\n }\n\n int numberOfSequence(int n, vector<int>...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\n\tusing ll = long long;\n\tconst ll mod = 1e9 + 7;\n\tll modExp(ll x, ll y, ll m){\n\t\tif(y == 0) return 1;\n\t\tll half_exp = modExp(x, y / 2, m);\n\t\tif(y % 2 == 0) return (half_exp * half_exp) % m;\n\t\telse return (((half_exp * half_exp) % m) * x) % m;\n\t}\npublic:\n\tint numberOfS...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\npublic:\n int numberOfSequence(int n, vector<int>& sick) {\n vector<long long> sec;\n for (int i = 1; i < sick.size(); ++i)\n if (sick[i]-sick[i-1]>1)\n sec.push_back(sick[i]-sick[i-1]-1);\n\n long long mod = 1e9 +7;\n vector<long l...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "class Solution {\npublic:\n const int MOD = 1e9 + 7;\n vector<long long> fact, inv_fact;\n\n void precomputeFactorials(int n) {\n fact.resize(n + 1);\n inv_fact.resize(n + 1);\n fact[0] = inv_fact[0] = 1;\n for(int i = 1; i <= n; ++i) {\n fact[i] = fact[i - 1...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "long long int f1(long long int n, long long int power){\n long long int mod = 1e9+7;\n if(power==0) return 1;\n if(power==1) return n%mod;\n long long int temp = f1(n,power/2);\n temp = (temp*temp)%mod;\n if(power%2) temp = temp*n;\n return temp%mod; \n}\n\nclass Solution {\npublic:\n ...
3,224
<p>You are given an integer <code>n</code> and an array <code>sick</code> sorted in increasing order, representing positions of infected people in a line of <code>n</code> people.</p> <p>At each step, <strong>one </strong>uninfected person <strong>adjacent</strong> to an infected person gets infected. This process con...
3
{ "code": "int mod = 1000000007;\nclass Solution {\npublic:\n int numberOfSequence(int n, vector<int>& s) {\n vector<int> xs;\n vector<int> a(n,0);\n for(auto i:s) a[i]=1;\n\n for(int i=0,cur=0;i<n;i++){\n if(!a[i]) cur++;\n\n if(!a[i] && (i==n-1 || a[i+1])){\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
0
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) \n {\n int count1=0, count2=0;\n for(auto i : nums1)\n {\n if(find(nums2.begin(), nums2.end(), i) != nums2.end())\n count1++;\n }\n\n for...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
0
{ "code": "#include <vector>\n#include <algorithm> // For std::find\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int count1 = 0;\n int count2 = 0;\n\n // Count elements from nums1 that are present in nums2\...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
0
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int> rlt{0,0};\n for(int num : nums1){\n if(find(nums2.begin(), nums2.end(), num) != nums2.end()){\n rlt.at(0)++;\n }\n }\n f...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
0
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int answer1{0}, answer2{0};\n int m = nums1.size()-1;\n int n = nums2.size()-1;\n int max = std::max(m,n);\n \n for(int i=0; i<= max; ++i){\n if...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
0
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& n1, vector<int>& n2) {\n int cnt1=0, cnt2=0;\n for(auto it1: n1) if(find(n2.begin(), n2.end(), it1)!=n2.end()) cnt1++;\n for(auto it1: n2) if(find(n1.begin(), n1.end(), it1)!=n1.end()) ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
0
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int rlt1 {0};\n int rlt2 {0};\n for(int num : nums1){\n if(find(nums2.begin(), nums2.end(), num) != nums2.end()){\n rlt1++;\n }\n }\...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
0
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int rlt1 {0};\n int rlt2 {0};\n for(int num : nums1){\n auto it = find(nums2.begin(), nums2.end(), num);\n if(it != nums2.end()){\n rlt1++;...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
0
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int rlt1 {0};\n int rlt2 {0};\n for(int num : nums1){\n auto it = find(nums2.begin(), nums2.end(), num);\n if(it != nums2.end()){\n rlt1++;...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int>ans(0,2);\n int count1=0;\n for(int i=0;i<nums1.size();i++){\n for(int j=0;j<nums2.size();j++){\n if(nums1[i]==nums2[j]){\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int>ans(0,2);\n int count1=0;\n for(int i=0;i<nums1.size();i++){\n for(int j=0;j<nums2.size();j++){\n if(nums1[i]==nums2[j]){\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n int count1 = 0;\n vector<int> ans;\n\n for (int i = 0; i < nums1.size(); ++i) {\n for (int j = 0; j <...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "/*\n method:\n 1. hash table: O(m + n)\n for each one, build the lut to let another look up\n \n 2. bin count: O(m + n)\n for each one, prepare their bin count\n then iterate each to find the res if both has count > 0 at i \n \n\n*/\nclass Solution {\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int>ans(2,0);\n vector<bool>storer(100,0);\n int cnt=0;\n for(int i=0;i<nums2.size();i++)\n storer[nums2[i]-1]=true;\n for(int i=0;i<nums1.size();i++)\...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) \n {\n int count=0;\n sort(nums1.begin(),nums1.end());\n sort(nums2.begin(),nums2.end());\n\n int i=0;\n int j=0;\n vector<int> fans;\n fans={0,0};\...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<bool> n1(101, false);\n vector<bool> n2(101, false);\n vector<int> answer;\n int n1freq = 0, n2freq = 0;\n for(auto n: nums1)\n n1[n] = true;\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<bool> n1(101, false);\n vector<bool> n2(101, false);\n vector<int> answer;\n int n1freq = 0, n2freq = 0;\n for(auto n: nums1)\n n1[n] = true;\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n\n\nint binary(vector<int> &arr,int target){\n int low=0;\n int high=arr.size()-1;\n\n while(high-low>1){\n\n int mid=(low+high)/2;\n\n if(arr[mid]>=target){\n high=mid;\n }\n else{\n l...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<bool> counts1(101, false);\n vector<bool> counts2(101, false);\n vector<int> answer(2, 0);\n\n for (const auto num : nums1) {\n counts1[num] = true;\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int> ans(2);\n int freq1[101] = {0}, freq2[101] = {0};\n for(int & i : nums1) {\n freq1[i]++;\n }\n for(int & i : nums2) {\n freq2[i]...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n \n vector<int> ans (2);\n \n int freq1[101]={0} , freq2[101]={0};\n\n \n for(int & i : nums1)\n freq1[i]++;\n\n \n for(int & i : n...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int> counts1(101, 0);\n vector<int> counts2(101, 0);\n vector<int> answer(2, 0);\n\n for (const auto num : nums1) {\n ++counts1[num];\n }\n\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int> a(101,0),b(101,0);\n for(auto it:nums1){\n a[it]=1;\n }\n for(auto it:nums2){\n b[it]=1;\n }\n int c=0,d=0;\n for(...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int> fre2(101),fre1(101);\n for(int i=0;i<nums1.size();i++)fre1[nums1[i]]++;\n for(int i=0;i<nums2.size();i++)fre2[nums2[i]]++;\n int anw1=0,anw2=0;\n for(...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "static const auto io_sync_off = []() {\n std::ios::sync_with_stdio(false);\n std::cin.tie(nullptr);\n return 0;\n}();\n// clang-format off\nusing ll = long long;\nusing SS = stringstream;\nusing pii = pair<int, int>; using pis = pair<int, string>; using psi = pair<string, int>;\ntemplate<typename ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n set<int> s;\n sort(nums1.begin(),nums1.end());\n sort(nums2.begin(),nums2.end());\n\n int i = 0,j = 0, n1 = nums1.size(),n2 = nums2.size();\n while(i<n1 && j<n2){...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": " class Solution {\n public:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n sort(nums1.begin(), nums1.end());\n sort(nums2.begin(), nums2.end());\n int n1 = nums1.size();\n int n2 = nums2.size();\n set<int>...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n sort(nums1.begin(), nums1.end());\n sort(nums2.begin(), nums2.end());\n int n1 = nums1.size();\n int n2 = nums2.size();\n set<int> nums3;\n int i = 0, j = ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n int countCommonIndices(vector<int> nums1, vector<int> nums2) {\n int count = 0;\n\n for (auto i : nums1) {\n for (auto j : nums2) {\n\n if (i == j) {\n\n count += 1;\n break;\n }\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n int countCommonIndices(vector<int> nums1, vector<int> nums2) {\n int answer = 0;\n\n for (auto i : nums1) {\n for (auto j : nums2) {\n\n if (i == j) {\n\n answer += 1;\n break;\n }\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int> answer(2);\n map<int, int> occurrences;\n for (int i = 0; i < nums1.size(); i++){\n if (occurrences.count(nums1[i]) == 0){\n occurrences.i...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\n\n int findLargeNumber(vector<int> nums) {\n int large = 0;\n for (int i = 0; i < nums.size(); i++) {\n if (nums[i] > large) {\n large = nums[i];\n }\n }\n return large;\n }\n\npublic:\n vector<int> findIntersection...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\n\n int findLargeNumber(vector<int> nums) {\n int large = 0;\n for (int i = 0; i < nums.size(); i++) {\n if (nums[i] > large) {\n large = nums[i];\n }\n }\n return large;\n }\n\npublic:\n vector<int> findIntersection...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
1
{ "code": "class Solution {\n\n int findLargeNumber(vector<int> nums) {\n int large = 0;\n for (int i = 0; i < nums.size(); i++) {\n if (nums[i] > large) {\n large = nums[i];\n }\n }\n return large;\n }\n\npublic:\n vector<int> findIntersection...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int, int> dict; \n int n = nums1.size();\n int m = nums2.size();\n int counter1 = 0;\n int counter2 = 0;\n for (int i = 0; i < n+m; i++...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int, int> Nums;\n\tvector<int> Result = { 0,0 };\n\n\tfor (size_t i = 0; i < nums1.size(); i++)\n\t{\n\t\tif (Nums.count(nums1.at(i)) == 0) Nums.emplace(nums1.at(i), 1);\n\t\telse ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int, int> freq;\n for(int i = 0; i < nums1.size(); i++)\n {\n if(freq.find(nums1[i]) != freq.end())\n {\n freq[nums1[i]]++;\n...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n map<int,int>mpp;\n int ans1=0,ans2=0;\n for(int x:nums1){\n mpp[x]++;\n } \n for(int x:nums2){\n if(mpp.find(x)!=mpp.end()){\n ans1+=mpp[x];\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "using namespace std;\nclass Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int ans1 = 0, ans2 = 0;\n map <int, int> intersection;\n map <int, int> mp;\n for(int it = 0; it < nums1.size(); it++)\n {\n mp[n...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int> ans1;\n vector<int> ans2;\n vector<int> vec;\n for(int i=0;i<nums1.size();i++)\n {\n for(int j=0;j<nums2.size();j++)\n {\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums, vector<int>& nums2) {\n\n vector<int>res;\n vector<int>nums1;\n map<int,int>mp;\n for(auto i:nums)\n {\n mp[i]++;\n }\n map<int, int>::iterator it ;\n for...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n map<int,int>m;\n vector<int> ans;\n int count1=0;\n int count2=0;\n for(int i=0;i<nums1.size();i++){\n m[nums1[i]]++;\n }\n for(int i=0;i...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int,int>mp;\n \n for(int i = 0;i<nums1.size();i++)\n {\n mp[nums1[i]]++;\n }\n \n int ans1 = 0;\n for(int i = 0;i<nu...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> hs;\n int ans1 = 0, ans2 = 0;\n\n for(int i = 0 ; i < nums2.size() ; i++) {\n hs.insert(nums2[i]);\n }\n\n for(int i = 0 ; i < nums1...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int,int> check;\n int answer1 = 0;\n int answer2 = 0;\n for(int i=0;i<nums1.size();i++)\n {\n check[nums1[i]]++;\n }\n\n fo...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n set<int> set1(nums1.begin(),nums1.end()),set2(nums2.begin(),nums2.end());\n int answer1=0,answer2=0;\n for(auto i:nums1)\n if(set2.find(i)!=set2.end())\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n int helper(vector<int>& nums1 , vector<int>& nums2){\n int n1 = nums1.size() ;\n int n2 = nums2.size() ;\n set<int> s ;\n for(int i = 0 ; i<n2 ; i++){\n s.insert(nums2[i]) ;\n } \n int ans = 0 ;\n for(int i = 0; i< n...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n set<int> set1(nums1.begin(), nums1.end()); // Unique elements from nums1\n set<int> set2(nums2.begin(), nums2.end()); // Unique elements from nums2\n \n int answer1 = 0; //...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n std::vector<int> findIntersectionValues(std::vector<int>& nums1, std::vector<int>& nums2) {\n std::set<int> set1(nums1.begin(), nums1.end());\n std::set<int> set2(nums2.begin(), nums2.end());\n\n int count1 = 0;\n for (int num : nums1) {\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n set<int> set1(nums1.begin(), nums1.end()); // Unique elements from nums1\n set<int> set2(nums2.begin(), nums2.end()); // Unique elements from nums2\n \n int answer1 = 0; //...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int>res;\n set<int>s1;\n set<int>s2;\n int m=nums1.size();\n int n=nums2.size();\n for(int i=0;i<m;i++){\n for(int j=0;j<n;j++){\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int,int> m1;\n unordered_map<int,int> m2;\n int one=0;\n int two=0;\n for(int i=0;i<nums1.size();i++){\n m1[nums1[i]]=i;\n }\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n\n int getCommon(vector<int>& a, vector<int>& b) {\n // common elms from b in a.\n unordered_set<int> uniqueNums;\n for(int x : a) {\n uniqueNums.insert(x);\n }\n\n int answer = 0;\n for(int num : b) {\n answer +=...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n\n int getCommon(vector<int>& a, vector<int>& b) {\n // common elms from b in a.\n unordered_set<int> uniqueNums;\n for(int x : a) {\n uniqueNums.insert(x);\n }\n\n int answer = 0;\n for(int num : b) {\n answer +=...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n set<int> s1,s2;\n for(auto i:nums1){\n s1.insert(i);\n }\n for(auto i:nums2){\n s2.insert(i);\n }\n int c1=0,c2=0;\n for(auto ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n map<int,int> m1;\n map<int,int> m2;\n for(int i : nums1){\n m1[i]++;\n }\n for(int i : nums2){\n m2[i]++;\n }\n\n vector<int> ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n map<int,int> m1,m2;\n for(int i=0;i<nums1.size();i++){\n m1[nums1[i]]++;\n }\n for(int i=0;i<nums2.size();i++){\n m2[nums2[i]]++;\n }\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int,int>mp1;\n unordered_map<int,int>mp2;\n for(auto it : nums1){\n mp1[it]++;\n }\n for(auto it : nums2){\n mp2[it]++;\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> s1(nums1.begin(), nums1.end());\n unordered_set<int> s2(nums2.begin(), nums2.end());\n int rlt1 {0};\n int rlt2 {0};\n for(int i = nums1.size()...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> s1(nums1.begin(), nums1.end());\n unordered_set<int> s2(nums2.begin(), nums2.end());\n int rlt1 {0};\n int rlt2 {0};\n for(int i = nums1.size()...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
2
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int cnt1=0;\n int cnt2=0;\n unordered_set<int>s1;\n unordered_set<int>s2;\n for(auto x:nums1){\n s1.insert(x);\n }\n for(auto x:nums2){\...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int,int>m1;\n unordered_map<int,int>m2;\n for(auto it : nums1) m1[it]++;\n for(auto it : nums2) m2[it]++;\n\n vector<int>ans;\n int count = 0...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int , int> m1;\n unordered_map<int , int> m2;\n\n vector<int> ans;\n int count1 = 0, count2 = 0;\n\n for( int i = 0 ; i< nums1.size(); i++){\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int>res;\n unordered_set<int>s1;\n unordered_set<int>s2;\n int m=nums1.size();\n int n=nums2.size();\n for(int i=0;i<m;i++){\n for(int j=...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int>ans(2,0);\n map<int,int>mp;\n map<int,int>mp1;\n for(auto t:nums1){\n mp[t]++;\n }\n for(auto t:nums2){\n mp1[t]++;\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int,int> mp2,mp1;\n int count1=0,count2=0;\n for(int i=0;i<nums2.size();i++)\n {\n mp2[nums2[i]]++;\n }\n \n for(int i=0;i...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "// ------------------------------------------------------------------------------------\n// Author: spexcher\n// Name: Gourab Modak\n// email: spexcher@gmail.com\n// Linktree: https://linktr.ee/spexcher/\n// Github: https://github.com/spexcher/\n// linkedin : https://www.linkedin.com/in/gourabmodak/\n// --...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int size1 = nums1.size(), size2 = nums2.size();\n unordered_map<int, int> map1;\n unordered_map<int, int> map2;\n for(int i = 0;i<size1;i++){\n map1[nums1[i]]...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int size1 = nums1.size(), size2 = nums2.size();\n unordered_map<int, int> map1;\n unordered_map<int, int> map2;\n for(int i = 0;i<size1;i++)\n map1[nums1[i]]+...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n map<int,int>mpp1;\n sort(nums1.begin(),nums1.end());\n sort(nums2.begin(),nums2.end());\n for(int i=0;i<nums1.size();i++)\n \n {\n mpp1[nums1[i]...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n map<int,int>mpp1;\n sort(nums1.begin(),nums1.end());\n sort(nums2.begin(),nums2.end());\n for(int i=0;i<nums1.size();i++)\n \n {\n mpp1[nums1[i]...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int size1 = nums1.size(), size2 = nums2.size();\n unordered_map<int, int> map1;\n unordered_map<int, int> map2;\n for(int i = 0;i<size1;i++){\n map1[nums1[i]]...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int size1 = nums1.size(), size2 = nums2.size();\n unordered_map<int, int> map1;\n unordered_map<int, int> map2;\n for(int i = 0;i<size1;i++){\n map1[nums1[i]]...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n if(nums1.empty() || nums2.empty()) return {0,0};\n unordered_map<int, int> nums1Map;\n unordered_map<int, int> nums2Map;\n\n vector<int> result = {0,0};\n\n for(i...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n if(nums1.empty() || nums2.empty()) return {0,0};\n unordered_map<int, int> nums1Map;\n unordered_map<int, int> nums2Map;\n\n vector<int> result = {0,0};\n\n for(i...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int,int> mp1,mp2;\n for(int i=0;i<nums1.size();++i)\n mp1[nums1[i]]++;\n for(int j=0;j<nums2.size();++j)\n mp2[nums2[j]]++;\n int x=0...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "#include <vector>\n#include <unordered_set>\n\nclass Solution {\npublic:\n std::vector<int> findIntersectionValues(const std::vector<int>& nums1, const std::vector<int>& nums2) {\n std::unordered_set<int> set1(nums1.begin(), nums1.end());\n std::unordered_set<int> set2(nums2.begin(), nums2...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int>ans1;\n vector<int>ans2;\n unordered_map<int,int>mp1;\n unordered_map<int,int>mp2;\n for(int i=0; i<nums1.size(); i++){\n mp1[nums1[i]]++;\n...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n // val, countOfVal\n map<int, int> count1;\n map<int, int> count2;\n\n for(int n : nums1) {\n count1[n]++;\n }\n\n for(int n : nums2) {\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int> v(2,0);\n unordered_map<int,int> mp1;\n unordered_map<int,int> mp2;\n\n for(int i=0;i<nums1.size();i++){\n mp1.insert({nums1[i],i});\n }\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n vector<int>answer(2,0);\n unordered_map<int,int>m1;\n unordered_map<int,int>m2;\n int n=nums1.size();\n int m=nums2.size();\n for(int i=0; i<n || i<m ; i++...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int, int> mp1;\n unordered_map<int, int> mp2;\n vector<int> ans(2);\n for(int i=0; i<nums1.size(); i++) {\n mp1[nums1[i]]++;\n }\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n unordered_map<int, int> mp1;\n unordered_map<int, int> mp2;\n vector<int> ans(2);\n for(int i=0; i<nums1.size(); i++) {\n mp1[nums1[i]]++;\n }\n ...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& v1, vector<int>& v2) {\n map<int,int>m1,m2;\n for(auto x:v1){\n m1[x]++;\n }\n for(auto x:v2){\n m2[x]++;\n }\n \n int c1=0,c2=0;\n for(int i=0;i<v1.size();i...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n map<int,int>maps1;\n map<int,int>maps2;\n for(int i=0;i<nums1.size();i++) {\n maps1[nums1[i]]++;\n }\n for(int i=0;i<nums2.size();i++) {\n m...
3,206
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of sizes <code>n</code> and <code>m</code>, respectively. Calculate the following values:</p> <ul> <li><code>answer1</code> : the number of indices <code>i</code> such that <code>nums1[i]</code> exists in <code>nums2</code>.</li> <li><code...
3
{ "code": "class Solution {\npublic:\n vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n int m = nums2.size();\n map<int,int> mp1, mp2;\n\n for(int i=0; i<n; i++) {\n mp1[nums1[i]]++;\n }\n for(int j=0; j<m; j...