Skip to content

Commit 0c95502

Browse files
committed
leetcode 334
1 parent 3da9484 commit 0c95502

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
10+
int solve(){
11+
int n,m;
12+
cin>>n>>m;
13+
vector<int> v(n+1,0);
14+
for(int i=0;i<m;i++){
15+
int temp;
16+
cin>>temp;
17+
v[temp]++;
18+
}
19+
int mini=INT_MAX;
20+
for(int i=1;i<=n;i++){
21+
mini=min(mini,v[i]);
22+
}
23+
cout<<mini<<endl;
24+
return 0;
25+
}
26+
int main()
27+
{
28+
int testCase=1;
29+
while(testCase--){
30+
solve();
31+
}
32+
return 0;
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
typedef long long ll ;
6+
const ll INF=1e18;
7+
const ll mod1=1e9+7;
8+
const ll mod2=998244353;
9+
//Add main code here
10+
11+
class Solution
12+
{
13+
public:
14+
vector<int> divisibilityArray(string word, int m)
15+
{
16+
vector<int> ans;
17+
long val = 0;
18+
for (auto &c : word)
19+
{
20+
val = (10 * val + (c - '0')) % m;
21+
if (val == 0)
22+
ans.push_back(1);
23+
else
24+
ans.push_back(0);
25+
}
26+
return ans;
27+
}
28+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
typedef long long ll ;
6+
const ll INF=1e18;
7+
const ll mod1=1e9+7;
8+
const ll mod2=998244353;
9+
//Add main code here
10+
11+
class Solution
12+
{
13+
public:
14+
int maxNumOfMarkedIndices(vector<int> &v)
15+
{
16+
sort(v.begin(), v.end());
17+
int i = 0, n = v.size(), j = n / 2, cnt = 0;
18+
while (i < n / 2 && j < n)
19+
{
20+
if (v[i] * 2 <= v[j])
21+
{
22+
i++;
23+
j++;
24+
cnt += 2;
25+
}
26+
else
27+
j++;
28+
}
29+
return cnt;
30+
}
31+
};

0 commit comments

Comments
 (0)