Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 98757c4

Browse files
leetacode: add 3223
1 parent 1c340db commit 98757c4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 minimumLength(string s)
15+
{
16+
vector<int> v(26, 0);
17+
int ans = 0;
18+
for (auto x : s)
19+
{
20+
v[x - 'a']++;
21+
}
22+
for (auto x : v)
23+
{
24+
if (x & 1)
25+
{
26+
ans++;
27+
}
28+
else if (x > 0)
29+
{
30+
ans += 2;
31+
}
32+
}
33+
34+
return ans;
35+
}
36+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /