Skip to content

Commit e5c4294

Browse files
authoredAug 4, 2020
Add files via upload
1 parent 8d04ac2 commit e5c4294

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2272
-0
lines changed
 

‎LC_1.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
vector<int> twoSum(vector<int>& nums, int target) {
4+
unordered_map<int,int>mp;
5+
vector<int>v;
6+
int i,len=nums.size();
7+
for(i=0;i<len;i++)
8+
{
9+
if(mp.find(target-nums[i])!=mp.end())
10+
{
11+
v.push_back(mp[target-nums[i]]);
12+
v.push_back(i);
13+
return v;
14+
}
15+
mp[nums[i]]=i;
16+
}
17+
return v;
18+
}
19+
};

‎LC_1018.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
vector<bool> prefixesDivBy5(vector<int>& A) {
4+
vector<bool>res;
5+
if(A.size()==0)
6+
return res;
7+
long long int i,sz=A.size(),val=A[0],con=0;
8+
if(val%5==0)
9+
res.push_back(true);
10+
else
11+
res.push_back(false);
12+
for(i=1;i<sz;i++)
13+
{
14+
val = (2*val + A[i])%5;
15+
if(val==0)
16+
res.push_back(true);
17+
else
18+
res.push_back(false);
19+
}
20+
return res;
21+
}
22+
};

0 commit comments

Comments
 (0)