We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3599f35 commit 1c340dbCopy full SHA for 1c340db
LeetCode/1400.Construct K Palindrome Strings.cpp
@@ -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
+ bool canConstruct(string s, int k)
15
+ {
16
+ vector<int> v(26,0);
17
+ int n = s.size();
18
+ for (auto x : s)
19
20
+ v[x-'a']++;
21
+ }
22
+ int odd = 0, even = 0;
23
+ for (auto x : v)
24
25
+ odd += (x % 2);
26
+ even += (x / 2);
27
28
+ k-=odd;
29
+ return k>=0 && k<=2*even;
30
31
+};
0 commit comments