question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
largest-number-after-digit-swaps-by-parity
Simple Map Approach
simple-map-approach-by-msegal347-veli
Code\n\nclass Solution:\n def largestInteger(self, num: int) -> int:\n # Convert number to a list of digits\n digits = [int(d) for d in str(num
msegal347
NORMAL
2024-06-12T19:50:15.302357+00:00
2024-06-12T19:50:15.302380+00:00
29
false
# Code\n```\nclass Solution:\n def largestInteger(self, num: int) -> int:\n # Convert number to a list of digits\n digits = [int(d) for d in str(num)]\n \n # Separate the digits by parity\n evens = sorted((d for d in digits if d % 2 == 0), reverse=True)\n odds = sorted((d fo...
1
0
['Python3']
0
largest-number-after-digit-swaps-by-parity
Python Max Heap Simple Solution
python-max-heap-simple-solution-by-asu2s-uqrl
Complexity\n- Time complexity: O(n*logn)\n\n- Space complexity: O(n)\n\n# Code\n\nclass Solution:\n def largestInteger(self, num: int) -> int:\n even,
asu2sh
NORMAL
2024-05-08T14:03:08.559043+00:00
2024-05-08T14:52:16.089889+00:00
255
false
# Complexity\n- Time complexity: $$O(n*logn)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```\nclass Solution:\n def largestInteger(self, num: int) -> int:\n even, odd = [], []\n nums = [-int(n) for n in str(num)]\n\n for n in nums:\n if n % 2:\n heapq.heappush(even, n)...
1
0
['Heap (Priority Queue)', 'Python3']
0
largest-number-after-digit-swaps-by-parity
Simple Java Code 0 ms beats 100 %
simple-java-code-0-ms-beats-100-by-arobh-14mn
Complexity\n\n# Code\n\nclass Solution {\n public int largestInteger(int num) {\n int count=0;\n int temp=num;\n while(temp>0){\n
Arobh
NORMAL
2024-05-07T01:27:49.602270+00:00
2024-05-07T01:27:49.602290+00:00
251
false
# Complexity\n![image.png](https://assets.leetcode.com/users/images/7d0119c6-13ed-4ff9-9b65-09b69ea67c8f_1715045246.978105.png)\n# Code\n```\nclass Solution {\n public int largestInteger(int num) {\n int count=0;\n int temp=num;\n while(temp>0){\n count++;\n temp/=10;\n ...
1
0
['Java']
0
largest-number-after-digit-swaps-by-parity
C++ Solution || 100%beats || using priority_queue || easy to understand
c-solution-100beats-using-priority_queue-5dqr
Code\n\nclass Solution {\npublic:\n int largestInteger(int num) {\n string numStr = to_string(num);\n priority_queue<int> oddDigits, evenDigits
harshil_sutariya
NORMAL
2024-04-11T09:20:53.695292+00:00
2024-04-11T09:22:34.414351+00:00
586
false
# Code\n```\nclass Solution {\npublic:\n int largestInteger(int num) {\n string numStr = to_string(num);\n priority_queue<int> oddDigits, evenDigits;\n\n for (char digit : numStr) {\n if ((digit - \'0\') % 2 == 0) {\n evenDigits.push(digit - \'0\');\n } else ...
1
0
['Heap (Priority Queue)', 'C++']
0
largest-number-after-digit-swaps-by-parity
Easiest Understandable Soln
easiest-understandable-soln-by-sumo25-fz4o
\n\n# Code\n\nclass Solution {\n public int largestInteger(int num) {\n PriorityQueue<Integer> odd=new PriorityQueue<>(Collections.reverseOrder());\n
sumo25
NORMAL
2024-03-06T21:02:15.028723+00:00
2024-03-06T21:02:15.028775+00:00
922
false
\n\n# Code\n```\nclass Solution {\n public int largestInteger(int num) {\n PriorityQueue<Integer> odd=new PriorityQueue<>(Collections.reverseOrder());\n PriorityQueue<Integer> even=new PriorityQueue<>(Collections.reverseOrder());\n String s=""+num;\n char[] ch=s.toCharArray();\n fo...
1
0
['Java']
0
largest-number-after-digit-swaps-by-parity
Two Different Solutions -- Simple and Easy
two-different-solutions-simple-and-easy-idp93
We first record the frequency of each digit in digitFreq list.\nNow we go through each digit of the number and replace it with the max number we have of the sam
mohit94596
NORMAL
2023-11-12T04:57:57.421970+00:00
2023-11-12T04:57:57.421994+00:00
175
false
We first record the frequency of each digit in digitFreq list.\nNow we go through each digit of the number and replace it with the max number we have of the same parity in digitFreq. Don\'t forget to decrease the freq once you reaplce. \nTC: 5 * O(n), because we have to go through a list of 5(out of 10, 5 are same pari...
1
0
['Heap (Priority Queue)', 'Python']
0
largest-number-after-digit-swaps-by-parity
Largest Number After Digit Swaps by Parity
largest-number-after-digit-swaps-by-pari-iplf
\n\n# Code\n\nclass Solution {\n public int largestInteger(int num) {\n ArrayList<Integer> lstEven=new ArrayList<>();\n ArrayList<Integer> lstO
riya1202
NORMAL
2023-11-01T13:01:13.890160+00:00
2023-11-01T13:01:13.890181+00:00
666
false
\n\n# Code\n```\nclass Solution {\n public int largestInteger(int num) {\n ArrayList<Integer> lstEven=new ArrayList<>();\n ArrayList<Integer> lstOdd=new ArrayList<>();\n ArrayList<Character> pos=new ArrayList<>();\n\n String s=""+num;\n\n for(int i=0;i<s.length();i++){\n ...
1
0
['Sorting', 'Heap (Priority Queue)', 'Java']
2
largest-number-after-digit-swaps-by-parity
Java int array (faster than 100%)
java-int-array-faster-than-100-by-coffee-q2ud
Code\n\nclass Solution {\n\n private int summarize(int[] digits, int length) {\n int result = 0;\n\n int multiplier = 1;\n for (int i =
coffeeminator
NORMAL
2023-10-30T14:44:41.767545+00:00
2023-10-30T14:44:41.767566+00:00
1,217
false
# Code\n```\nclass Solution {\n\n private int summarize(int[] digits, int length) {\n int result = 0;\n\n int multiplier = 1;\n for (int i = length - 1; i >= 0; i--) {\n result += digits[i] * multiplier;\n multiplier *= 10;\n }\n\n return result;\n }\n\n ...
1
0
['Java']
1
largest-number-after-digit-swaps-by-parity
JS || Easy to understand
js-easy-to-understand-by-k4zhymukhan-ztun
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
K4zhymukhan
NORMAL
2023-10-22T15:55:42.289739+00:00
2023-10-22T15:55:42.289764+00:00
200
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['JavaScript']
0
largest-number-after-digit-swaps-by-parity
Very slow solution based on PQueue. Also version for odd and even digits positions.
very-slow-solution-based-on-pqueue-also-wnx05
Code\n\npublic class Solution {\n public int LargestInteger(int n) {\n int num = n;\n var odd = new PriorityQueue<int, int>();\n var eve
thrillobit
NORMAL
2023-07-24T19:06:31.120709+00:00
2023-07-24T19:06:31.120737+00:00
49
false
# Code\n```\npublic class Solution {\n public int LargestInteger(int n) {\n int num = n;\n var odd = new PriorityQueue<int, int>();\n var even = new PriorityQueue<int, int>();\n\n while (num>0) {\n if ( (num%10)%2 == 0)\n odd.Enqueue(num%10, num%10);\n ...
1
0
['Heap (Priority Queue)', 'C#']
0
largest-number-after-digit-swaps-by-parity
JS | Priority Queue | Heap
js-priority-queue-heap-by-darcyrush-57ub
Code\n\n/**\n * @param {number} num\n * @return {number}\n */\nvar largestInteger = function(num) {\n let numArr = num.toString().split(\'\').map(d => Number(d
darcyrush
NORMAL
2023-04-20T10:58:02.379936+00:00
2023-04-20T10:58:02.379974+00:00
262
false
# Code\n```\n/**\n * @param {number} num\n * @return {number}\n */\nvar largestInteger = function(num) {\n let numArr = num.toString().split(\'\').map(d => Number(d))\n\n let oddQ = new MaxPriorityQueue({\n compare: (a, b) => (a < b)\n })\n \n let evenQ = new MaxPriorityQueue({\n compare: (a, b) => (a < b)\n...
1
0
['Heap (Priority Queue)', 'JavaScript']
0
largest-number-after-digit-swaps-by-parity
Python: Optimal and Clean with explanation: O(nlogn) time and O(n) space
python-optimal-and-clean-with-explanatio-yhx2
Approach\n Describe your approach to solving the problem. \n1. get the set of indicies of odd parity elem. \n2. sort the values there descending\n3. same with r
topswe
NORMAL
2022-12-20T00:34:30.267584+00:00
2023-02-02T04:07:07.389813+00:00
183
false
# Approach\n<!-- Describe your approach to solving the problem. -->\n1. get the set of indicies of odd parity elem. \n2. sort the values there descending\n3. same with remaining set of indicies of even parity elem\n4. now rewire each index according to the sorted order of its odd/even list.\n# Complexity\n$$n = \\log(n...
1
0
['Python3']
1
largest-number-after-digit-swaps-by-parity
Typescript | Javascript, 100% faster
typescript-javascript-100-faster-by-toha-nz30
\nfunction largestInteger(num: number): number {\n const oddSet = new Set(\'13579\'.split(\'\'));\n const digits = num.toString().split(\'\');\n const
tohasan
NORMAL
2022-09-28T19:35:26.478027+00:00
2022-09-28T19:35:26.478068+00:00
86
false
```\nfunction largestInteger(num: number): number {\n const oddSet = new Set(\'13579\'.split(\'\'));\n const digits = num.toString().split(\'\');\n const oddDigits = sort(digits.filter(d => oddSet.has(d)));\n const evenDigits = sort(digits.filter(d => !oddSet.has(d)));\n \n let numStr = \'\';\n for...
1
0
['TypeScript', 'JavaScript']
0
largest-number-after-digit-swaps-by-parity
✅ [Rust] 0 ms, two solutions (with detailed comments)
rust-0-ms-two-solutions-with-detailed-co-08if
This solution employs quadtratic-time swaps that are cheap due to the small size of array of digits. It demonstrated 0 ms runtime (100%) and used 2.0 MB memory
stanislav-iablokov
NORMAL
2022-09-10T15:02:46.600990+00:00
2022-10-23T12:58:26.700425+00:00
77
false
This [solution](https://leetcode.com/submissions/detail/796326742/) employs quadtratic-time swaps that are cheap due to the small size of array of digits. It demonstrated **0 ms runtime (100%)** and used **2.0 MB memory (71.43%)**. Detailed comments are provided.\n\n**IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n```\ni...
1
0
['Rust']
0
largest-number-after-digit-swaps-by-parity
JAVA easy solution using List
java-easy-solution-using-list-by-21arka2-vlhq
\nclass Solution {\n public int largestInteger(int n) {\n List<Integer>e=new ArrayList<>();\n List<Integer>o=new ArrayList<>();\n List<I
21Arka2002
NORMAL
2022-09-09T15:28:43.135972+00:00
2022-09-09T15:28:43.136008+00:00
603
false
```\nclass Solution {\n public int largestInteger(int n) {\n List<Integer>e=new ArrayList<>();\n List<Integer>o=new ArrayList<>();\n List<Integer>num=new ArrayList<>();\n while(n>0)\n {\n num.add(n%10);\n if((n%10)%2==0)e.add(n%10);\n else o.add(n%1...
1
0
['Array', 'Java']
0
largest-number-after-digit-swaps-by-parity
Python MaxHeap Solution
python-maxheap-solution-by-sharmanihal96-8bp9
\nclass Solution:\n def largestInteger(self, num: int) -> int:\n evenHeap=[]\n oddHeap=[]\n digits = [int(x) for x in str(num)]\n
sharmanihal96
NORMAL
2022-08-21T07:46:21.361380+00:00
2022-08-21T07:46:21.361412+00:00
25
false
```\nclass Solution:\n def largestInteger(self, num: int) -> int:\n evenHeap=[]\n oddHeap=[]\n digits = [int(x) for x in str(num)]\n for i in digits:\n if i %2==0:\n heappush(evenHeap,i*-1)\n else:\n heappush(oddHeap,i*-1)\n max=\...
1
0
[]
0
largest-number-after-digit-swaps-by-parity
C++ easy solution for beginner using priority queue
c-easy-solution-for-beginner-using-prior-zz3z
Pls upvote if it\'s helpful\n\nint largestInteger(int num) \n {\n priority_queue<int>e;\n priority_queue<int>o ;\n int temp=0 ;\n
ayushpanchal0523
NORMAL
2022-07-29T19:22:02.882840+00:00
2022-07-29T19:22:02.882880+00:00
102
false
**Pls upvote if it\'s helpful**\n```\nint largestInteger(int num) \n {\n priority_queue<int>e;\n priority_queue<int>o ;\n int temp=0 ;\n while(num>0)\n {\n int x=num%10 ;\n if(x%2==0)\n e.push(x);\n else \n o.push(x) ;...
1
0
['C', 'Heap (Priority Queue)']
0
largest-number-after-digit-swaps-by-parity
3ms Java Solution (Priority Queue)
3ms-java-solution-priority-queue-by-gite-n6hd
\tclass Solution {\n\t\tpublic int largestInteger(int num) {\n\t\t\tQueue q1 = new PriorityQueue<>(Collections.reverseOrder());\n\t\t\tQueue q2 = new PriorityQu
Gitesh054
NORMAL
2022-07-24T08:43:59.957118+00:00
2022-07-24T08:43:59.957161+00:00
115
false
\tclass Solution {\n\t\tpublic int largestInteger(int num) {\n\t\t\tQueue<Integer> q1 = new PriorityQueue<>(Collections.reverseOrder());\n\t\t\tQueue<Integer> q2 = new PriorityQueue<>(Collections.reverseOrder());\n\t\t\tString x = num+"";\n\t\t\tint[] nums = new int[x.length()];\n\t\t\tfor(int i=0 ;i<nums.length; i++) ...
1
0
['Heap (Priority Queue)']
1
largest-number-after-digit-swaps-by-parity
100% FASTER AND EASY TO UNDERSTAND ( USNIG PRIORITY QUEUE)
100-faster-and-easy-to-understand-usnig-1wlge
\tclass Solution {\n\tpublic:\n\t\tint largestInteger(int num) {\n\t\t\tvectorv;\n\t\t\tpriority_queuepqe;// EVEN PRIORITY QUEUE\n\t\t\tpriority_queuepqo;// ODD
mahan07122001
NORMAL
2022-07-24T08:41:35.226849+00:00
2022-07-24T08:51:02.455809+00:00
122
false
\tclass Solution {\n\tpublic:\n\t\tint largestInteger(int num) {\n\t\t\tvector<int>v;\n\t\t\tpriority_queue<int>pqe;// EVEN PRIORITY QUEUE\n\t\t\tpriority_queue<int>pqo;// ODD PRIORITY QUEUE\n\t\t\tlong long sum=0;\n\t\t\twhile(num){\n\t\t\t\tint k=num%10;\n\t\t\t\tv.push_back(k); // PUSHING IN VECTOR\n\t\t\t\tif(k%2==...
1
0
['C', 'Heap (Priority Queue)']
0
largest-number-after-digit-swaps-by-parity
Java - PriorityQueue - 1 ms
java-priorityqueue-1-ms-by-abanoubcs-a74s
\nclass Solution {\n public int largestInteger(int num) {\n PriorityQueue < Integer > odd = new PriorityQueue < Integer > ();\n PriorityQueue <
abanoubcs
NORMAL
2022-07-20T19:06:43.632839+00:00
2022-07-20T19:07:45.902568+00:00
66
false
```\nclass Solution {\n public int largestInteger(int num) {\n PriorityQueue < Integer > odd = new PriorityQueue < Integer > ();\n PriorityQueue < Integer > even = new PriorityQueue < Integer > ();\n int n = num;\n while (n > 0) {\n if (n % 2 == 0) {\n even.offer...
1
0
[]
0
largest-number-after-digit-swaps-by-parity
C / 0ms / 100% t / 93% s
c-0ms-100-t-93-s-by-tonicaletti-usmm
\nint cmp(void* u, void* v)\n{\n return *(int*)u - *(int*)v;\n}\n\nint largestInteger(int num){\n\n int* u = malloc(10*sizeof(int));\n int* g = malloc(
tonicaletti
NORMAL
2022-07-17T09:49:54.953879+00:00
2022-07-17T09:49:54.953921+00:00
86
false
```\nint cmp(void* u, void* v)\n{\n return *(int*)u - *(int*)v;\n}\n\nint largestInteger(int num){\n\n int* u = malloc(10*sizeof(int));\n int* g = malloc(10*sizeof(int));\n int* f = malloc(10*sizeof(int));\n \n int i_g = 0, i_u = 0, i_f = 0;\n while(num > 0)\n {\n int r = num % 10;\n ...
1
0
[]
0
largest-number-after-digit-swaps-by-parity
python easy selection sort
python-easy-selection-sort-by-sonusahu05-k0f2
\tclass Solution:\n\t\tdef largestInteger(self, num: int) -> int:\n\t\t\tarr=[int(i) for i in str(num)]\n\t\t\tprint(arr)\n\t\t\t#selection sort\n\t\t\tfor i in
sonusahu050502
NORMAL
2022-07-14T09:28:04.565521+00:00
2022-07-14T09:28:04.565556+00:00
310
false
\tclass Solution:\n\t\tdef largestInteger(self, num: int) -> int:\n\t\t\tarr=[int(i) for i in str(num)]\n\t\t\tprint(arr)\n\t\t\t#selection sort\n\t\t\tfor i in range(0,len(arr)):\n\t\t\t#selection sort for odd numbers\n\t\t\t\tif arr[i]%2!=0:\n\t\t\t\t\tmaxi=i\n\t\t\t\t\tfor j in range(i+1,len(arr)):\n\t\t\t\t\t\tif a...
1
0
['Python']
0
largest-number-after-digit-swaps-by-parity
Faster Than 100% || Easy || Priority Queue
faster-than-100-easy-priority-queue-by-a-pa29
\nclass Solution {\npublic:\n int largestInteger(int num) {\n string snum = to_string(num), result;\n priority_queue<int> even, odd;\n i
Aakarsh_Inamdar
NORMAL
2022-07-01T08:29:06.957054+00:00
2022-07-01T08:29:06.957091+00:00
140
false
```\nclass Solution {\npublic:\n int largestInteger(int num) {\n string snum = to_string(num), result;\n priority_queue<int> even, odd;\n int rtn_val;\n \n for(int i=0; i < snum.length(); i++){\n if(((int)snum[i]) % 2 == 0){\n even.push((int)snum[i]-48);\n...
1
0
['String', 'C', 'Heap (Priority Queue)']
0
largest-number-after-digit-swaps-by-parity
C++||0ms || Easy to Understand
c0ms-easy-to-understand-by-adnor-cbkz
```\nclass Solution {\npublic:\n int largestInteger(int num) {\n int n=num;\n vectorv;\n priority_queueheap1, heap2;\n while(n){\
Adnor
NORMAL
2022-06-25T18:15:41.619275+00:00
2022-06-25T18:15:41.619321+00:00
140
false
```\nclass Solution {\npublic:\n int largestInteger(int num) {\n int n=num;\n vector<int>v;\n priority_queue<int>heap1, heap2;\n while(n){\n int remain = n%10;\n v.push_back(remain);\n if(remain%2==0){\n heap1.push(remain);\n }\n ...
1
0
['C']
0
largest-number-after-digit-swaps-by-parity
C++ || priority queue
c-priority-queue-by-jatin837-ufbk
use two priority queue(one for odd and other for even) and replace each digit according to it\'s parity from queue.\n\nc++\n\nclass Solution {\npublic:\n int
jatin837
NORMAL
2022-06-21T11:33:50.733125+00:00
2022-06-24T11:36:36.634759+00:00
158
false
use two priority queue(one for odd and other for even) and replace each digit according to it\'s parity from queue.\n\n```c++\n\nclass Solution {\npublic:\n int largestInteger(int num) {\n string n = to_string(num);\n priority_queue<char>opq;\n priority_queue<char>epq;\n for(char ch:n){\n ...
1
0
['C', 'Heap (Priority Queue)']
1
construct-k-palindrome-strings
[Java/C++/Python] Straight Forward
javacpython-straight-forward-by-lee215-9hfu
Intuition\nCondition 1. odd characters <= k\nCount the occurrences of all characters.\nIf one character has odd times occurrences,\nthere must be at least one p
lee215
NORMAL
2020-04-04T16:09:29.099269+00:00
2020-07-15T15:11:45.919619+00:00
20,426
false
# **Intuition**\nCondition 1. `odd characters <= k`\nCount the occurrences of all characters.\nIf one character has odd times occurrences,\nthere must be at least one palindrome,\nwith odd length and this character in the middle.\nSo we count the characters that appear odd times,\nthe number of odd character should not...
253
5
[]
35
construct-k-palindrome-strings
✅🔥BEATS 99%🔥 || 3 UNIQUE APPROACHES TO Construct K Palindrome Strings 💡|| CONCISE CODE ✅
beats-99-3-unique-approaches-to-construc-yi9j
💡IntuitionThe problem revolves around the frequency of characters in a string. To construct palindromes: Characters with odd frequencies must be the centers of
RSPRIMES1234
NORMAL
2025-01-11T02:18:38.385546+00:00
2025-01-11T14:15:26.320764+00:00
18,663
false
![image.png](https://assets.leetcode.com/users/images/9e0c10d2-2543-41a4-97cc-67526440bfce_1736604917.92514.png) # 💡Intuition The problem revolves around the frequency of characters in a string. To construct palindromes: 1. Characters with **odd frequencies** must be the centers of palindromes. 2. The number o...
104
2
['C++', 'Java', 'Go', 'Python3', 'Ruby', 'C#']
9
construct-k-palindrome-strings
[java/Python 3] Count odd occurrences - 2 codes w/ brief explanation and analysis.
javapython-3-count-odd-occurrences-2-cod-63d5
Explanation of the method - credit to @lionkingeatapple\nIf we need to construct k palindromes, and each palindrome at most has1 character with odd times of occ
rock
NORMAL
2020-04-04T16:02:00.765058+00:00
2022-09-04T05:56:32.595619+00:00
4,454
false
**Explanation of the method** - credit to **@lionkingeatapple**\nIf we need to construct `k` palindromes, and each palindrome at most has`1` character with odd times of occurrence. The oddest times of occurrence we can have is `1 * k = k`. Therefore, `oddNum <= k`. And it is impossible to construct `k` palindromes when...
44
2
[]
6
construct-k-palindrome-strings
Clear Python 3 solution faster than 91% with explanation
clear-python-3-solution-faster-than-91-w-4wxy
\nfrom collections import Counter\n\nclass Solution:\n def canConstruct(self, s: str, k: int) -> bool:\n if k > len(s):\n return False\n
swap24
NORMAL
2020-08-24T08:33:18.152121+00:00
2020-08-25T14:04:57.538767+00:00
3,084
false
```\nfrom collections import Counter\n\nclass Solution:\n def canConstruct(self, s: str, k: int) -> bool:\n if k > len(s):\n return False\n h = Counter(s)\n countOdd = 0\n for value in h.values():\n if value % 2:\n countOdd += 1\n if countOdd > ...
38
0
['Python', 'Python3']
5
construct-k-palindrome-strings
✅||Easy solutions||[with proof]||Beats 100% in most||🔥|🐍|C#️⃣|C➕➕|☕|💎|🔥🔥
easy-solutionswith-proofbeats-100-in-mos-4cp0
HELLOW PLEZ UPVOTE!! Intuition💡 A palindrome is a string that reads the same forward and backward. For constructing a palindrome: Characters must appear in
AbyssReaper
NORMAL
2025-01-11T07:53:54.394063+00:00
2025-01-11T07:53:54.394063+00:00
149
false
- # ***********************HELLOW PLEZ UPVOTE!!*********************** ![beats 100% .png](https://assets.leetcode.com/users/images/2927a2ed-c3e0-4221-af75-b6c3ca14ac2d_1736581868.0719783.png) # Intuition💡 - A palindrome is a string that reads the same forward and backward. - For constructing a palindrome: 1. Charact...
29
0
['C', 'Python', 'C++', 'Java', 'Ruby', 'JavaScript', 'C#']
2
construct-k-palindrome-strings
✅ Simple Freq Count Detailed Solution
easy-by-sumeet_sharma-1-a5qb
Can Construct Palindromes 🏗️Problem Understanding 🤔Given a string s and a number k, we need to determine if we can construct exactly k palindromes using the cha
Sumeet_Sharma-1
NORMAL
2025-01-11T05:01:42.544772+00:00
2025-01-11T05:02:32.150407+00:00
4,106
false
# **Can Construct Palindromes** 🏗️ ### **Problem Understanding** 🤔 Given a string `s` and a number `k`, we need to determine if we can construct exactly `k` palindromes using the characters from `s`. --- ## **Intuition** 💡 - A **palindrome** is a string that reads the same forward and backward. - For constructin...
25
1
['String', 'C', 'Counting', 'C++', 'Java', 'Python3', 'JavaScript', 'C#']
5
construct-k-palindrome-strings
only consider the parity of freq+bitset|Py3 1-liner|C++ beats 100%
only-consider-the-parity-of-freq-bitsetb-3tk3
IntuitionFollow the hints. This problem becomes fairly easy.The key observation: palindrome strings of even lengths have all letters even occurrences, palindrom
anwendeng
NORMAL
2025-01-11T00:33:12.478355+00:00
2025-01-11T13:08:03.808279+00:00
1,955
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> Follow the hints. This problem becomes fairly easy. The key observation: palindrome strings of even lengths have all letters even occurrences, palindrome strings of odd lengths have all letters even occurrences but except one letter with o...
22
4
['Greedy', 'Bit Manipulation', 'C++', 'Python3']
5
construct-k-palindrome-strings
✅🔥BEATS 100% PROOF🔥||🌟JAVA | C++ | C# | PYTHON💡|| CONCISE CODE✅||
beats-100-proofconcise-codejava-beginner-k96r
Proof 💯Problem Analysis 🧠We are given a string s and an integer k. The goal is to determine if we can use all the characters in s to construct exactly k palindr
mukund_rakholiya
NORMAL
2025-01-11T00:10:57.258378+00:00
2025-01-11T00:27:11.533185+00:00
1,649
false
# Proof 💯 --- ![image.png](https://assets.leetcode.com/users/images/00067014-b0d4-41d2-a839-14e0518c6984_1736553993.7984586.png) ``` ``` # Problem Analysis 🧠 --- We are given a string `s` and an integer `k`. The goal is to determine if we can use all the characters in `s` to construct exactly `k` palindrome strings...
16
3
['String', 'Bit Manipulation', 'Counting', 'Python', 'C++', 'Java', 'C#']
8
construct-k-palindrome-strings
C++ Super Simple Solution, Only 6 Short Lines
c-super-simple-solution-only-6-short-lin-jr76
\nclass Solution {\npublic:\n bool canConstruct(string s, int k) {\n if (s.size() < k) return false;\n \n vector<int> freq(26);\n
yehudisk
NORMAL
2021-07-14T16:07:50.948189+00:00
2021-07-14T16:07:50.948219+00:00
1,538
false
```\nclass Solution {\npublic:\n bool canConstruct(string s, int k) {\n if (s.size() < k) return false;\n \n vector<int> freq(26);\n for (auto ch : s) freq[ch - \'a\']++;\n \n int odd = 0;\n for (auto f : freq) odd += (f % 2);\n \n return odd <= k;\n ...
16
2
['C']
4
construct-k-palindrome-strings
Counting | String | Solution for LeetCode#1400
counting-string-solution-for-leetcode140-w5qq
IntuitionThe problem asks if it's possible to construct k palindromic strings using all characters from the given string s. The key insight is that palindromes
samir023041
NORMAL
2025-01-11T00:27:15.273722+00:00
2025-01-11T00:53:31.248430+00:00
1,360
false
![image.png](https://assets.leetcode.com/users/images/529eef1b-750e-40a9-a152-c84ff563dbfc_1736555164.2082756.png) # Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem asks if it's possible to construct k palindromic strings using all characters from the given string s. The key i...
15
6
['Python', 'Java', 'Python3']
3
construct-k-palindrome-strings
25ms | 100% Beats | PHP
25ms-100-beats-php-by-ma7med-m8xd
Code
Ma7med
NORMAL
2025-01-11T09:07:03.365788+00:00
2025-01-15T08:39:33.742627+00:00
480
false
# Code ```php [] class Solution { /** * @param String $s * @param Integer $k * @return Boolean */ function canConstruct($s, $k) { // If k is greater than the length of s, it's impossible to construct k palindromes if ($k > strlen($s)) { return false; } ...
14
0
['PHP']
0
construct-k-palindrome-strings
✅🔥BEATS 100%🔥|| 🌟✅ Efficient Palindrome Building: A Beginner-Friendly Solution! 🧩💡|| Approved ✅
beats-100-efficient-palindrome-building-54bpx
IntuitionThe problem is to check whether we can rearrange the characters of the string s to form exactly k palindrome strings. Key observations: A palindrome ca
venkat_pasapuleti
NORMAL
2025-01-11T04:05:14.287232+00:00
2025-01-11T04:49:36.469749+00:00
502
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem is to check whether we can rearrange the characters of the string `s` to form exactly `k` palindrome strings. Key observations: - A **palindrome** can have at most one character with an odd frequency. - To form `k` palindromes...
11
0
['C', 'C++', 'Java', 'Python3', 'JavaScript']
4
construct-k-palindrome-strings
0ms | Beats 100%| Using Bitmask Based (13Line) | Efficient & Easy C++ Solu| Full Explain| With Proof
0ms-beats-100-using-bitmask-based-13line-ux3m
IntuitionThe problem revolves around determining whether a given string can be split into k palindromic substrings. A palindrome is a string that reads the same
HarshitSinha
NORMAL
2025-01-11T01:31:46.256875+00:00
2025-01-11T01:31:46.256875+00:00
422
false
![11 jan.jpg](https://assets.leetcode.com/users/images/b59bfc2b-a279-4fae-8530-ab585ec81ea6_1736557655.6304543.jpeg) # Intuition The problem revolves around determining whether a given string can be split into k palindromic substrings. A palindrome is a string that reads the same forward and backward. The key to solv...
10
1
['Hash Table', 'String', 'Greedy', 'Bit Manipulation', 'Counting', 'Ordered Set', 'Counting Sort', 'Bitmask', 'C++']
2
construct-k-palindrome-strings
⚡⚡⚡One-Liner Solution with Efficient Checks ✅⚡⚡⚡
one-liner-solution-with-efficient-checks-oqap
IntuitionThe problem involves determining if a string s can be rearranged into k palindromes. Each palindrome can have at most one character with an odd frequen
suhas_sr7
NORMAL
2025-01-11T15:14:11.281991+00:00
2025-01-11T15:14:11.281991+00:00
194
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem involves determining if a string `s` can be rearranged into `k` palindromes. Each palindrome can have at most one character with an odd frequency (in the middle), and the rest must appear in pairs. This means the number of cha...
9
0
['Python3']
0
construct-k-palindrome-strings
Java, counting, simple, explained
java-counting-simple-explained-by-gthor1-6guy
Idea is following: count of chars can be even or odd. Those that are even - they can be used in one of substrings to form the palindrome, so we don\'t care abou
gthor10
NORMAL
2020-04-05T03:50:06.888346+00:00
2020-04-05T03:50:06.888401+00:00
1,848
false
Idea is following: count of chars can be even or odd. Those that are even - they can be used in one of substrings to form the palindrome, so we don\'t care about those.\nIf character has odd frequency - it can be inserted only 1 or 3 or 5... etc. to form the palindrome. However number of such characters cannot be more ...
9
0
['String', 'Java']
2
construct-k-palindrome-strings
Most Optimized Solution | ✅Beats 100% | C++| Java | Python | JavaScript
most-optimized-solution-beats-100-c-java-2p5w
IntuitionTo construct k palindromes, we need to understand that each palindrome can have at most one character with odd frequency (in the middle). Therefore, th
BijoySingh7
NORMAL
2025-01-11T04:28:36.629306+00:00
2025-01-11T04:28:36.629306+00:00
1,214
false
```cpp [] class Solution { public: bool canConstruct(string s, int k) { if (k > s.length()) return false; int charCount[26] = {0}; for (char c : s) { charCount[c - 'a']++; } int oddCount = 0; for (int i = 0; i < 26; i++) { if (charCount[i] % 2 ...
8
1
['String', 'Greedy', 'Counting', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
13
construct-k-palindrome-strings
Hash | Simple Logic | Beats 100%
hash-simple-logic-beats-100-by-sparker_7-v7dl
IntuitionOdd count characters will create problems for palindrome.All the odd frequency characters can be used as a single character string which is always a pa
Sparker_7242
NORMAL
2025-01-11T10:49:34.086834+00:00
2025-01-11T10:49:34.086834+00:00
46
false
![image.png](https://assets.leetcode.com/users/images/5dccd259-f85f-4ae9-9d45-c6950765ea18_1736592402.4685996.png) # Intuition Odd count characters will create problems for palindrome. **All the odd frequency characters can be used as a single character string which is always a palindrome. E.g. "a","g","l","v", etc....
7
0
['Hash Table', 'String', 'Counting', 'C++']
1
construct-k-palindrome-strings
💻🧠BEST SOLUTION✅| BEATS 100%⌛⚡| (C++/Java/Python3/Javascript)
best-solution-beats-100-cjavapython3java-pa1i
IntuitionTo form a palindrome, all characters must have even counts, except for at most one character with an odd count (which can be placed in the middle of th
Fawz-Haaroon
NORMAL
2025-01-11T08:45:50.630835+00:00
2025-01-11T10:04:38.610259+00:00
47
false
# **Intuition** To form a palindrome, all characters must have even counts, except for at most one character with an odd count (which can be placed in the middle of the palindrome). To construct `k` palindromes: 1. The number of palindromes cannot exceed the number of characters in the string (`k <= s.length`). 2. ...
7
1
['Python', 'C++', 'Java', 'Python3', 'JavaScript']
0
construct-k-palindrome-strings
[Java] O(n) Time and O(1) Space Beats 100%
java-on-time-and-o1-space-beats-100-by-b-a8kt
We can just simply use a 26 bit integer to store the set bits and then use XOR to flip the bits. \n\nclass Solution {\n public boolean canConstruct(String s,
blackspinner
NORMAL
2020-04-04T18:20:33.007619+00:00
2022-08-20T01:02:07.700115+00:00
1,257
false
We can just simply use a 26 bit integer to store the set bits and then use XOR to flip the bits. \n```\nclass Solution {\n public boolean canConstruct(String s, int k) {\n int odd = 0;\n \n for (int i = 0; i < s.length(); i++) {\n odd ^= 1 << (s.charAt(i) - \'a\');\n }\n ...
7
0
[]
1
construct-k-palindrome-strings
✅100% || C++ || Python || 🎈Hash Table || ✨Bit-Set || 🚀Beginner-Friendly
100-c-python-hash-table-bit-set-beginner-os2r
IntuitionThe main idea is to count the number of characters with odd frequencies in the string s. A palindrome can have at most one character with an odd freque
Rohithaaishu16
NORMAL
2025-01-11T04:56:34.154725+00:00
2025-01-11T04:56:34.154725+00:00
143
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The main idea is to count the number of characters with odd frequencies in the string `s`. A palindrome can have at most one character with an odd frequency (this would be the middle character in case of odd-length palindromes). Therefore, ...
6
0
['Hash Table', 'String', 'Greedy', 'Counting', 'C++', 'Python3']
0
construct-k-palindrome-strings
✅✅ easiest approach ever 🔥🔥
easiest-approach-ever-by-ishanbagra-nd7g
Intuition The problem revolves around the properties of palindromes. A string can only form a palindrome if it has at most one character with an odd frequency.
ishanbagra
NORMAL
2025-01-11T04:21:15.667218+00:00
2025-01-11T04:21:15.667218+00:00
328
false
Intuition The problem revolves around the properties of palindromes. A string can only form a palindrome if it has at most one character with an odd frequency. Hence, the number of palindromes we can form from a string depends on the frequency of its characters. The key insight is: If the length of the string is less...
6
0
['C++']
3
construct-k-palindrome-strings
C++ Easy T.C.:O(n) and S.C:O(1), beats 98.4% in T.C. and 95% in S.C.
c-easy-tcon-and-sco1-beats-984-in-tc-and-dkes
Intuition: \nCount for the number of charachters having odd number of occurences\n Describe your first thoughts on how to solve this problem. \n\n# Approach:\nI
aryanshsingla
NORMAL
2022-12-14T13:10:11.812747+00:00
2022-12-14T17:22:26.833179+00:00
1,317
false
# Intuition: \nCount for the number of charachters having odd number of occurences\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach:\nIf the number of odd occurences of charachters are less than k, we can partition the string in k no.of palndromes.We are counting for odd occurences bec...
6
0
['Greedy', 'C++']
0
construct-k-palindrome-strings
Easy C++ Explaination O(N) using Map
easy-c-explaination-on-using-map-by-avi1-mqux
class Solution {\npublic:\n\n// we can have only odd number of a particular char only one time in a pallindrome\n ```\n bool canConstruct(string s, in
avi1273619
NORMAL
2022-08-05T11:01:21.573137+00:00
2022-08-05T11:05:55.984465+00:00
616
false
class Solution {\npublic:\n\n// we can have only odd number of a particular char only one time in a pallindrome\n ```\n bool canConstruct(string s, int k) \n{\n\t\t if(s.size()<k)\n\t\t\t\treturn false;\n unordered_map<char,int> frq;\n for(int i=0;i<s.size();i++)\n {\n ...
6
1
['C']
1
construct-k-palindrome-strings
Simple JAVA Solution
simple-java-solution-by-ruchita56-jhgj
-Count all odd number of characters in string and check whether they are less or equal to k\n\npublic boolean canConstruct(String s, int k) {\n\t\tif(s.length()
ruchita56
NORMAL
2021-07-20T18:13:30.354024+00:00
2021-07-20T18:13:30.354068+00:00
686
false
-Count all odd number of characters in string and check whether they are less or equal to k\n```\npublic boolean canConstruct(String s, int k) {\n\t\tif(s.length()<k) {\n\t\t\treturn false;\n\t\t}\n\t\tHashMap<Character,Integer> map=new HashMap<>();\n\t\tfor(char c:s.toCharArray()) {\n\t\t\tmap.put(c,map.getOrDefault(c...
6
0
['Java']
0
construct-k-palindrome-strings
[Python] count odd
python-count-odd-by-zy07621-ggh8
\nclass Solution:\n def canConstruct(self, s: str, k: int) -> bool:\n \n if len(s) < k:\n return False\n \n dic = {}\n
zy07621
NORMAL
2020-04-04T16:04:23.442196+00:00
2020-04-04T16:04:23.442249+00:00
708
false
```\nclass Solution:\n def canConstruct(self, s: str, k: int) -> bool:\n \n if len(s) < k:\n return False\n \n dic = {}\n for x in s:\n if x not in dic:\n dic[x] = 1\n else:\n dic[x] += 1\n \n odd = 0\n ...
6
1
[]
2
construct-k-palindrome-strings
[C++] Number of Odd frequency character
c-number-of-odd-frequency-character-by-n-i1mb
If k is more than n then palindromes are never possible.\nOtherwise, if the odd frequency character count is less than k, you can always make k palindromes.\n\n
nicmit
NORMAL
2020-04-04T16:02:44.348437+00:00
2020-04-04T16:07:53.691812+00:00
1,074
false
If `k` is more than `n` then palindromes are never possible.\nOtherwise, if the odd frequency character count is less than `k`, you can always make `k` palindromes.\n\nFor example : `s = Leetcode` and `k = 5`\n\nWe have odd freq characters : `{L, e, t, c, o, d}` , we can create 5 palindromes, but then atleast one of th...
6
0
[]
2
construct-k-palindrome-strings
3 Line | Best Easy Solution | Beginner Friendly | O(n) Time :)
3-line-best-easy-solution-beginner-frien-jlu8
IntuitionThe problem revolves around the concept of constructing palindromes, which is heavily influenced by the frequency of characters in the string. A palind
azhan-born-to-win
NORMAL
2025-01-11T02:38:37.234512+00:00
2025-01-11T02:38:37.234512+00:00
227
false
--- # Intuition The problem revolves around the concept of constructing palindromes, which is heavily influenced by the frequency of characters in the string. A palindrome can tolerate at most one character with an odd frequency, as this odd character can occupy the center of the palindrome. The rest of the characters...
5
0
['Python3']
1
construct-k-palindrome-strings
Swift 100%
swift-100-by-shafiq-bd-04-5mjo
IntuitionThe goal is to determine if it's possible to construct k palindromes using all characters of the string s. Palindromes have at most one character with
shafiq-bd-04
NORMAL
2025-01-11T00:27:46.158588+00:00
2025-01-11T00:27:46.158588+00:00
88
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The goal is to determine if it's possible to construct k palindromes using all characters of the string s. Palindromes have at most one character with an odd frequency (for odd-length palindromes) or all even frequencies (for even-length pa...
5
0
['Swift']
1
construct-k-palindrome-strings
Best Solution for Arrays 🚀 in C++, Python and Java || 100% working
best-solution-for-arrays-in-c-python-and-ra0k
Intuition💡 First, we observe that a palindrome can only have at most one character with an odd frequency. If there are more odd-frequency characters than k, it'
BladeRunner150
NORMAL
2025-01-12T05:53:15.328990+00:00
2025-01-12T05:53:15.328990+00:00
27
false
# Intuition 💡 First, we observe that a palindrome can only have at most **one character with an odd frequency**. If there are more odd-frequency characters than `k`, it's impossible to split the string into `k` palindromes. # Approach 1. 🧮 Count the frequency of each character. 2. 🔢 Count how many character...
4
0
['Hash Table', 'String', 'Greedy', 'Counting', 'Python', 'C++', 'Java', 'Python3']
0
construct-k-palindrome-strings
Chill Solution for a chill guy || 😶‍🌫 Chill efficienty BEATS 100%!!! 😶‍🌫
chill-solution-for-a-chill-guy-chill-eff-7l9z
I'm just a chill guy that solved this problem...Chill Codeme:Please Upvote 🙏🏽🙏🏽🙏🏽!!!!
mattebiroo
NORMAL
2025-01-11T23:15:48.043924+00:00
2025-01-11T23:15:48.043924+00:00
15
false
I'm just a chill guy that solved this problem... # Chill Code ```cpp [] class Solution { public: bool canConstruct(string s, int k) { unordered_map<char, int> hMap; set<char> cKeys; int cOdds = 0; int cEven = 0; int totCE = 0; for(char ch : s){ cKeys.inse...
4
0
['C++']
1
construct-k-palindrome-strings
Simple py,JAVA code explained in detail!
simple-pyjava-code-explained-in-detail-b-e1vy
Problem understanding Given a string s and integer k. They are asking us to find whether it is possible to construct k palindromes. Approach:Counting+GreedyIntu
arjunprabhakar1910
NORMAL
2025-01-11T14:51:31.087029+00:00
2025-01-11T14:51:31.087029+00:00
52
false
# Problem understanding - Given a string `s` and integer `k`. - They are asking us to find whether it is possible to construct `k` palindromes. --- # Approach:Counting+Greedy <!-- Describe your approach to solving the problem. --> # Intuition <!-- Describe your first thoughts on how to solve this problem. --> - The...
4
0
['Hash Table', 'String', 'Greedy', 'Counting', 'Python', 'Java']
0
construct-k-palindrome-strings
✅ One Line Solution
one-line-solution-by-mikposp-wc4m
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)Code #1Time complexity: O(n). Space complexity: O(1)
MikPosp
NORMAL
2025-01-11T10:57:41.367499+00:00
2025-01-11T11:25:23.650429+00:00
205
false
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly) # Code #1 Time complexity: $$O(n)$$. Space complexity: $$O(1)$$. ```python3 class Solution: def canConstruct(self, s: str, k: int) -> bool: return sum(f&1 for f in Counter(s).values())<=k<=len(s) ``...
4
0
['Hash Table', 'String', 'Counting', 'Python', 'Python3']
1
construct-k-palindrome-strings
🎯Easy explanation || O(n) || Greedy Approach 🚀
easy-explanation-on-greedy-approach-by-c-jovw
Intuition If the s.length < k we cannot construct k strings from s and answer is false. If the number of characters that have odd counts is > k then the minimum
cs_balotiya
NORMAL
2025-01-11T10:48:01.419589+00:00
2025-01-11T10:48:01.419589+00:00
5
false
# Intuition 1. If the s.length < k we cannot construct k strings from s and answer is false. 2. If the number of characters that have odd counts is > k then the minimum number of palindrome strings we can construct is > k and answer is false. 3. Otherwise you can construct exactly k palindrome strings and answer is tru...
4
0
['C++']
0
construct-k-palindrome-strings
Eassyyy Pessyyy Solution ✅ | Runtime 91.82%🔥| TC = O(n) 🔥| SC = O(1) 🔥
eassyyy-pessyyy-solution-runtime-9182-tc-3je3
IntuitionThe problem involves determining whether it's possible to construct k palindrome strings from the given string s. Palindromes have specific properties:
jaitaneja333
NORMAL
2025-01-11T04:14:49.336665+00:00
2025-01-11T04:15:27.626152+00:00
178
false
# Intuition #### The problem involves determining whether it's possible to construct k palindrome strings from the given string s. Palindromes have specific properties: * A string can be rearranged into a palindrome if at most one character has an odd frequency (for a single palindrome). * For multiple palindromes, th...
4
0
['Hash Table', 'String', 'Counting', 'C++']
3
construct-k-palindrome-strings
Easy C++ solution with explanation
easy-c-solution-with-explanation-by-itsm-yxv1
IntuitionWe can make a palindrome if we have one character which occurs a single time and rest occur in pairs, or if all the characters occur in pairs. example
itsme_S
NORMAL
2025-01-11T03:02:11.651362+00:00
2025-01-11T03:02:11.651362+00:00
78
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> We can make a palindrome if we have one character which occurs a single time and rest occur in pairs, or if all the characters occur in pairs. example - in aabaa: a occurs in pairs two times while b occurs a single time # Approach <!-- Des...
4
0
['C++']
0
construct-k-palindrome-strings
🚀 Efficient Single-Pass Solution | Fully Explained & Well-Commented 🔍| Check this out once
efficient-single-pass-solution-fully-exp-widg
IntuitionIn a palindrome, all characters must appear an even number of times, except for at most one character that can appear an odd number of times (to occupy
Bulba_Bulbasar
NORMAL
2025-01-11T00:54:16.897402+00:00
2025-01-11T00:54:16.897402+00:00
262
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> In a palindrome, all characters must appear an even number of times, except for at most one character that can appear an odd number of times (to occupy the middle position). Therefore, the number of characters with odd frequencies determine...
4
0
['Hash Table', 'String', 'C', 'C++', 'Java', 'JavaScript', 'C#']
2
construct-k-palindrome-strings
simple bitmask
simple-bitmask-by-theyta-v8dp
IntuitionApproachComplexity Time complexity: O(n) Space complexity: O(1)Code
theyta
NORMAL
2025-01-11T00:23:35.368907+00:00
2025-01-11T00:23:35.368907+00:00
80
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> $$O(n)$$ - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> $...
4
0
['Rust']
2
construct-k-palindrome-strings
[javascript] -One Line Solution
javascript-one-line-solution-by-charnavo-rfev
please upvote, you motivate me to solve problems in original ways
charnavoki
NORMAL
2025-01-11T00:20:18.657737+00:00
2025-01-11T00:20:18.657737+00:00
191
false
```javascript [] const canConstruct = (s, k, frequencies = Object.values([...s].reduce((o, v) => (o[v] = (o[v]|0) + 1, o), {}))) => s.length >= k && frequencies.filter(n => n%2).length <= k; ``` #### please upvote, you motivate me to solve problems in original ways
4
0
['JavaScript']
0
construct-k-palindrome-strings
JAVA SOLUTION
java-solution-by-tejasmesta-ok7c
class Solution {\n public boolean canConstruct(String s, int k) {\n\t\n int n = s.length();\n \n if(n<k)\n {\n return
tejasmesta
NORMAL
2022-09-12T14:30:20.691785+00:00
2022-09-12T14:30:20.691846+00:00
745
false
class Solution {\n public boolean canConstruct(String s, int k) {\n\t\n int n = s.length();\n \n if(n<k)\n {\n return false;\n }\n \n HashMap<Character,Integer> map = new HashMap<>();\n \n for(int i=0;i<n;i++)\n {\n char c = ...
4
0
['Java']
1
construct-k-palindrome-strings
C++ solution based on pidgeonhole principle
c-solution-based-on-pidgeonhole-principl-z4rn
If we have more odd frequency characters than palindromes, then at least 2 odd frequency characters must be in the same palindrome. Since this is not possible,
nc_
NORMAL
2020-07-07T17:52:15.758997+00:00
2020-07-07T17:52:15.759029+00:00
347
false
If we have more odd frequency characters than palindromes, then at least 2 odd frequency characters must be in the same palindrome. Since this is not possible, we return true if we have fewer or equal to k odd frequency characters.\n\n```\nclass Solution {\npublic:\n bool canConstruct(string s, int k) {\n if ...
4
0
[]
0
construct-k-palindrome-strings
python 1line
python-1line-by-shtarkon-lzic
\nreturn len(s) >= k and sum(i % 2 for i in Counter(s).values()) <= k\n
shtarkon
NORMAL
2020-04-04T16:08:55.695758+00:00
2020-04-04T16:08:55.695812+00:00
192
false
```\nreturn len(s) >= k and sum(i % 2 for i in Counter(s).values()) <= k\n```
4
2
[]
1
construct-k-palindrome-strings
💢Faster✅💯 Lesser C++✅Python3🐍✅Java✅C✅Python🐍✅C#✅💥🔥💫Explained☠💥🔥 Beats 💯
faster-lesser-cpython3javacpythoncexplai-bnow
IntuitionApproach JavaScript Code --> https://leetcode.com/problems/construct-k-palindrome-strings/submissions/1505165242 C++ Code --> https://leetcode.com/prob
Edwards310
NORMAL
2025-01-11T15:10:27.148430+00:00
2025-01-11T15:10:27.148430+00:00
57
false
![0ehh83fsnh811.jpg](https://assets.leetcode.com/users/images/9fc46acb-7ba4-42e1-864c-3b0e7e0e82b6_1730795144.4340796.jpeg) # Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your first thoughts on how to solve this problem. --> - ***JavaScript Code -->*** https:...
3
0
['Hash Table', 'C', 'Counting', 'Python', 'C++', 'Java', 'Go', 'Python3', 'JavaScript', 'C#']
0
construct-k-palindrome-strings
Easiest C++ Solution | Count Method
easiest-c-solution-count-method-by-vinee-id0a
IntuitionApproachComplexity Time complexity: Space complexity: Code
vineetvermaa30
NORMAL
2025-01-11T11:45:38.454872+00:00
2025-01-11T11:45:38.454872+00:00
84
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
3
0
['C++']
0
construct-k-palindrome-strings
🔥BEATS 💯 % 🎯 |✨SUPER EASY BEGINNERS 👏| With illustrative diagram
beats-super-easy-beginners-with-illustra-sfkp
Problem: Construct k Palindrome StringsGiven a string s and an integer k, determine if it is possible to construct exactly k palindrome strings using all the ch
CodeWithSparsh
NORMAL
2025-01-11T11:39:19.583973+00:00
2025-01-11T11:42:53.384929+00:00
63
false
![image.png](https://assets.leetcode.com/users/images/77e9d4ae-42dd-4862-aca8-5f07c1411980_1736595465.0244067.png) --- ![1000060782.png](https://assets.leetcode.com/users/images/627a80cc-2efa-4302-804f-f3ac966d5c79_1736595768.5801446.png) --- ### Problem: Construct k Palindrome Strings Given a string `s` and an in...
3
0
['Hash Table', 'Greedy', 'C', 'Counting', 'C++', 'Java', 'Go', 'Python3', 'JavaScript', 'Dart']
2
construct-k-palindrome-strings
✅ Easiest & Efficient code | Beats 100% 💯
easiest-efficient-code-beats-100-by-yoge-0k0b
IntuitionTo form a palindrome: Characters with even frequencies can be fully used without issues. Characters with odd frequencies require at least one separate
yogeshm01
NORMAL
2025-01-11T11:39:11.177841+00:00
2025-01-11T11:39:11.177841+00:00
14
false
# Intuition To form a palindrome: - Characters with even frequencies can be fully used without issues. - Characters with odd frequencies require at least one separate palindrome to fit their "extra" character. So, the key idea is: - Count how many characters have odd frequencies. - If the number of these "odd ...
3
0
['Python']
0
construct-k-palindrome-strings
construct-k-palindrome-strings
construct-k-palindrome-strings-by-yadav_-brkj
Code
Yadav_Akash_
NORMAL
2025-01-11T09:30:12.748723+00:00
2025-01-11T09:30:12.748723+00:00
14
false
# Code ```java [] class Solution { public boolean canConstruct(String s, int k) { if(k>s.length()){ return false; } int freq[]=new int[26]; for(int i=0;i<s.length();i++){ freq[s.charAt(i)-'a']++; } int count=0; for(int i=0;i<freq.lengt...
3
0
['Java']
0
construct-k-palindrome-strings
Kotlin. Beats 100% (3 ms). Counting odd bits (bitwise solution).
kotlin-beats-100-3-ms-counting-odd-bits-83h02
Code
mobdev778
NORMAL
2025-01-11T08:24:49.506667+00:00
2025-01-11T08:24:49.506667+00:00
39
false
![image.png](https://assets.leetcode.com/users/images/082b93ec-43ad-4d6f-8f7f-1dab849c4c10_1736583876.5047762.png) # Code ```kotlin [] class Solution { fun canConstruct(s: String, k: Int): Boolean { if (s.length < k) return false var bits = 0 val s = s.toCharArray() for (c in s) { ...
3
0
['Kotlin']
1
construct-k-palindrome-strings
100% faster code in O(n) time and O(1) space
100-faster-code-in-on-time-and-o1-space-11qmj
IntuitionWe need to find if we can make k palindromes by shuffling the alphabets of a string.ApproachSo we will count the number of alphabets those are present
madhavgarg2213
NORMAL
2025-01-11T08:09:49.347395+00:00
2025-01-11T08:09:49.347395+00:00
70
false
# Intuition We need to find if we can make k palindromes by shuffling the alphabets of a string. <!-- Describe your first thoughts on how to solve this problem. --> # Approach So we will count the number of alphabets those are present odd number of times, as each palindrome can have at most 1 odd occurance character. ...
3
0
['String', 'Greedy', 'Counting', 'C++']
0
construct-k-palindrome-strings
🔥 BEATS 100 %🔥✅ || Construct K Palindrome Strings in ONE PASS 💡|| Optimal Code Approach✅
beats-100-construct-k-palindrome-strings-7bth
IntuitionA string can be rearranged into a palindrome if at most one character has an odd frequency. Given k, we need to determine if we can construct exactly k
EmPty063
NORMAL
2025-01-11T05:30:56.781207+00:00
2025-01-11T05:30:56.781207+00:00
45
false
![Screenshot 2025-01-11 104057.png](https://assets.leetcode.com/users/images/1d19b529-88ab-40cd-a622-ad4cde973a8a_1736573127.2752535.png) # Intuition A string can be rearranged into a palindrome if at most one character has an odd frequency. Given `k`, we need to determine if we can construct exactly `k` palindromic s...
3
0
['String', 'C++']
0
construct-k-palindrome-strings
Construct k palindrome strings - Easy Explanation 🔜
construct-k-palindrome-strings-easy-expl-0smr
Intuition If the number of palindrome k is greater than the length of the string s, then no such k palindrome can be made from the string s. If the number of
RAJESWARI_P
NORMAL
2025-01-11T05:27:36.650336+00:00
2025-01-11T05:27:36.650336+00:00
25
false
# Intuition 1. If the number of palindrome k is greater than the length of the string s, then no such k palindrome can be made from the string s. 1. If the number of palindrome k is equal to the length of the string s, then each single character in the string s is actually palindrome. 1. Atleast each palindrome const...
3
0
['String', 'Counting', 'Java']
0
construct-k-palindrome-strings
Java 🍵 | Easy ✅ | Beats 95% 🔥 | TC: O(n) 📈 | SC: O(1) 🤯 - Optimal Solution
java-easy-beats-95-tc-on-sc-o1-optimal-s-17zu
ComplexityCode
mani-26
NORMAL
2025-01-11T03:06:31.191550+00:00
2025-01-11T03:06:31.191550+00:00
117
false
# Complexity ![image.png](https://assets.leetcode.com/users/images/2cbe0f64-6441-43ae-b432-64110d18bc0e_1736564531.0767372.png) ![image.png](https://assets.leetcode.com/users/images/fd1dfcc5-34c8-464a-8b5b-7f7871757be0_1736564521.8281696.png) # Code ```java [] class Solution { public boolean canConstruct(Strin...
3
0
['Hash Table', 'String', 'Greedy', 'Counting', 'Java']
0
construct-k-palindrome-strings
Only Count Odd Frequencies - Explanation | C++, Python, Java
only-count-odd-frequencies-explanation-c-b0hy
ApproachWe can use a greedy approach to find our solution. In our greedy approach, we'll mostly only focus on palindromes consisting of one specific character u
not_yl3
NORMAL
2025-01-11T00:43:43.283561+00:00
2025-01-11T00:43:43.283561+00:00
281
false
# Approach <!-- Describe your approach to solving the problem. --> We can use a greedy approach to find our solution. In our greedy approach, we'll mostly only focus on palindromes consisting of one specific character until the end. First we'll get the frequency of each character in `s` with a frequency array `freq[26]...
3
0
['Hash Table', 'String', 'Greedy', 'C', 'Counting', 'Python', 'C++', 'Java', 'Python3']
0
construct-k-palindrome-strings
Beginner Friendly[c++]
beginner-friendlyc-by-gopalagks-h444
\nclass Solution {\npublic:\n bool canConstruct(string s, int k) {\n unordered_map<char,int>mp;\n int counte=0,counto=0;\n for(auto ch:s
gopalagks
NORMAL
2022-01-08T03:24:08.465488+00:00
2022-06-03T05:48:35.987156+00:00
174
false
```\nclass Solution {\npublic:\n bool canConstruct(string s, int k) {\n unordered_map<char,int>mp;\n int counte=0,counto=0;\n for(auto ch:s){\n mp[ch]++;\n }\n for(auto it:mp){\n if(it.second%2==0){\n counte++;\n }else{\n ...
3
0
[]
0
construct-k-palindrome-strings
[JS] O(n) solution with comments
js-on-solution-with-comments-by-wintryle-xse3
\nvar canConstruct = function(s, k) {\n\t// if string length is less than k, we cannot form k palindromes from the string, so return false\n if(k > s.length)
wintryleo
NORMAL
2021-08-22T18:28:48.057362+00:00
2021-08-22T21:41:21.969656+00:00
374
false
```\nvar canConstruct = function(s, k) {\n\t// if string length is less than k, we cannot form k palindromes from the string, so return false\n if(k > s.length) {\n return false;\n }\n\t// created a map to keep count of each letter in the string\n const map = new Map(); // O(26)\n for(let i = 0; i...
3
0
['JavaScript']
0
construct-k-palindrome-strings
[Java] Short & Concise
java-short-concise-by-manrajsingh007-wzd8
```\nclass Solution {\n public boolean canConstruct(String s, int k) {\n int n = s.length();\n if(k > n) return false;\n if(k == n) retu
manrajsingh007
NORMAL
2020-04-04T16:02:36.282789+00:00
2020-04-04T16:02:36.282829+00:00
142
false
```\nclass Solution {\n public boolean canConstruct(String s, int k) {\n int n = s.length();\n if(k > n) return false;\n if(k == n) return true;\n int[] arr = new int[26];\n for(int i = 0; i < n; i++) arr[s.charAt(i) - \'a\']++;\n int singles = 0;\n for(int i = 0; i <...
3
3
[]
0
construct-k-palindrome-strings
C++ Check Odd Count
c-check-odd-count-by-votrubac-8784
Intuition: a palindrome can have no more than one odd letter in the middle. If a string has n odd letters, we cannot construct less than n palindromes.\n\ncpp\n
votrubac
NORMAL
2020-04-04T16:02:33.085130+00:00
2020-04-04T16:11:27.315742+00:00
182
false
Intuition: a palindrome can have no more than one odd letter in the middle. If a string has `n` odd letters, we cannot construct less than `n` palindromes.\n\n```cpp\nbool canConstruct(string s, int k) {\n if (k >= s.size())\n return k == s.size();\n bool cnt[26] = {};\n for (auto ch : s)\n cnt[c...
3
3
[]
0
construct-k-palindrome-strings
PYTHON💡|| CONCISE CODE✅||
python-concise-code-by-pbs_gopi-0imc
Complexity Time complexity: Space complexity: Code
pbs_gopi
NORMAL
2025-01-12T06:22:44.167767+00:00
2025-01-12T06:22:44.167767+00:00
5
false
# Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> O(n) - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> O(1) # Code ```python3 [] from collections import Counter class Solution: def canConstruct(self, s: str, k: int) -> bool: num=0 ...
2
0
['Python3']
0
construct-k-palindrome-strings
2-Approaches : Better | Optimal.
2-approaches-better-optimal-by-priyans_r-a979
Approach 1: Store the count of all characters in vector. Run a loop till 26-time. If any count of character occur odd time so add in the 'cnt' variable. If 'cnt
priyans_raj
NORMAL
2025-01-11T23:00:46.295633+00:00
2025-01-11T23:00:46.295633+00:00
3
false
# Approach 1: <!-- Describe your approach to solving the problem. --> 1. Store the count of all characters in vector. 2. Run a loop till 26-time. 3. If any count of character occur odd time so add in the 'cnt' variable. 4. If 'cnt' cross the 'k' so it cannot be palindrome. # Complexity - Time complexity: O(N + 26) <!--...
2
0
['C++']
0
construct-k-palindrome-strings
Easy C++ Beats 100%
easy-c-beats-100-by-abhishek-verma01-zxx0
IntuitionThe problem boils down to understanding the properties of palindromes and how character frequencies contribute to their formation: A palindrome can hav
Abhishek-Verma01
NORMAL
2025-01-11T19:48:01.665832+00:00
2025-01-11T19:48:01.665832+00:00
18
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem boils down to understanding the properties of palindromes and how character frequencies contribute to their formation: 1. A palindrome can have at most one character with an odd frequency. 2. To create multiple palindrome...
2
0
['String', 'Greedy', 'Counting', 'C++']
0
construct-k-palindrome-strings
Solutions - Count Odd Frequencies and Bit manipulation
solutions-count-odd-frequencies-and-bit-yzlp1
IntuitionWe are given a string s composed of lowercase letters and an integer k. Our goal is to determine if it's possible to rearrange the characters of the st
rohity821
NORMAL
2025-01-11T15:12:31.901019+00:00
2025-01-11T15:12:31.901019+00:00
14
false
# Intuition We are given a string `s` composed of lowercase letters and an integer `k`. Our goal is to determine if it's possible to rearrange the characters of the string into exactly `k` palindromic substrings. A palindrome is a string that reads the same forward and backward, showing symmetry with respect to its ce...
2
0
['Hash Table', 'String', 'Greedy', 'Swift', 'Counting']
1
construct-k-palindrome-strings
"Checking Feasibility of Constructing 𝑘 k Palindromes from a String"
checking-feasibility-of-constructing-k-k-6o4h
IntuitionThe problem revolves around understanding the properties of palindromes. A palindrome can have at most one character with an odd frequency. Therefore,
ankita_molak21
NORMAL
2025-01-11T15:02:18.170424+00:00
2025-01-11T15:02:18.170424+00:00
6
false
# Intuition The problem revolves around understanding the properties of palindromes. A palindrome can have at most one character with an odd frequency. Therefore, to construct k palindrome strings, the minimum number of palindromes required is determined by the number of characters with odd frequencies. If k is less th...
2
0
['Hash Table', 'String', 'Greedy', 'Counting', 'C++']
0
construct-k-palindrome-strings
🔥Explanations No One Will Give You🎓🧠 Very Easy C++ Solution✅✨ 🚀Beats 💯 % on LeetCode🚀🎉!!
explanations-no-one-will-give-you-very-e-2x9i
IntuitionFirst of all on reading the question, I noticed a few conditions for getting a palindrome like the smallest palindrome string can be a letter itself an
codonaut_anant_05
NORMAL
2025-01-11T14:21:31.437284+00:00
2025-01-11T14:21:31.437284+00:00
10
false
# Intuition First of all on reading the question, I noticed a few conditions for getting a palindrome like the smallest palindrome string can be a letter itself and the letter at the middle of the palindrome string is having an odd frequency always. Now keeping these conditions in mind I tried to code the solution to t...
2
0
['C++']
0
construct-k-palindrome-strings
Easy Approach
easy-approach-by-sriharshabhoomandla-u8f3
IntuitionTo construct k palindromes from the string s, we need: At least k characters in the string. If s.size() < k, it is impossible, so return false. Each pa
sriharshabhoomandla
NORMAL
2025-01-11T13:55:20.493806+00:00
2025-01-11T13:55:20.493806+00:00
10
false
# Intuition To construct k palindromes from the string s, we need: 1. At least k characters in the string. If s.size() < k, it is impossible, so return false. 2. Each palindrome can have at most one character with an odd frequency. Therefore, the total number of characters with odd frequencies in s must not exceed k. ...
2
0
['C++']
0
construct-k-palindrome-strings
🌟 HashMap & Counting Made Simple! 🔢 | Beginner-Friendly 🐣 | O(N) Solution 🚀
hashmap-counting-made-simple-beginner-fr-4e3z
Intuition : 💡We aim to split the string s into exactly k palindromic substrings. Palindromes need at most 1 odd-frequency character 🔑. Count odd-frequency chara
mansimittal935
NORMAL
2025-01-11T13:52:44.878267+00:00
2025-01-11T13:52:44.878267+00:00
88
false
# Intuition : 💡 We aim to split the `string` `s` into exactly `k` palindromic substrings. - Palindromes need `at most 1 odd-frequency` character 🔑. - Count odd-frequency characters . If there are more odd characters than `k`, it’s impossible to form `k` palindromes. --- # Approach 🔍 1. ***Edge Check***: If s.si...
2
0
['Hash Table', 'String', 'Greedy', 'Counting', 'C++', 'Java', 'TypeScript', 'Rust', 'JavaScript', 'Dart']
0
construct-k-palindrome-strings
🧩Form K Palindromes ✨with Minimal Effort 🧠✅
form-k-palindromes-with-minimal-effort-b-r2zi
Intuition 🤔✨We need to check if the string s can be split into k palindromes. Palindrome Fact: Only odd-frequency characters matter when forming palindromes (si
shubhamrajpoot_
NORMAL
2025-01-11T13:45:02.356580+00:00
2025-01-11T13:45:02.356580+00:00
49
false
# Intuition 🤔✨ We need to check if the string s can be split into k palindromes. - Palindrome Fact: Only odd-frequency characters matter when forming palindromes (since the middle character can stay unmatched). - So, the question boils down to: 1. Count the characters with odd frequencies. 2. Check if we can ...
2
0
['Swift', 'Counting', 'Python', 'C++', 'Java', 'Go', 'Rust', 'Ruby', 'JavaScript', 'C#']
0
construct-k-palindrome-strings
C++ Solution + YouTube Tutorial 🎬💖
c-solution-youtube-tutorial-by-ra_zan-hlch
IntuitionTo determine if a string can be split into exactly k palindromes, the key insight is understanding the properties of palindromes: A palindrome can have
ra_zan
NORMAL
2025-01-11T13:40:56.146505+00:00
2025-01-11T13:40:56.146505+00:00
7
false
# Intuition To determine if a string can be split into exactly `k` palindromes, the key insight is understanding the properties of palindromes: 1. A palindrome can have at most **one character** with an odd frequency. 2. The number of characters with odd frequencies determines the **minimum number of palindromes** need...
2
0
['Hash Table', 'String', 'Greedy', 'Counting', 'C++']
0
construct-k-palindrome-strings
beats 100% || frequency array
beats-100-frequency-array-by-akshatchawl-rcc3
IntuitionEach palindrmic string can have only one non pair element. So there must be max k elements with odd frequency in the given string.ApproachComplexity Ti
akshatchawla1307
NORMAL
2025-01-11T13:20:30.421683+00:00
2025-01-11T13:20:30.421683+00:00
4
false
# Intuition Each palindrmic string can have only one non pair element. So there must be max k elements with odd frequency in the given string. <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O(N) <!-...
2
0
['C++']
0
construct-k-palindrome-strings
✅ ⟣ Java Solution ⟢
java-solution-by-harsh__005-n8da
Code
Harsh__005
NORMAL
2025-01-11T10:35:27.584450+00:00
2025-01-11T10:35:27.584450+00:00
13
false
# Code ```java [] class Solution { public boolean canConstruct(String s, int k) { int n = s.length(); if(n < k) return false; else if(n == k) return true; int[] ct = new int[26]; for(char ch : s.toCharArray()) { ct[ch-'a']++; } int oddct = 0; ...
2
0
['Java']
1
construct-k-palindrome-strings
✅✅Beats 100%🔥Java🔥Python|| 🚀🚀Super Simple and Efficient Solution🚀🚀||🔥Python🔥Java✅✅
beats-100javapython-super-simple-and-eff-rr9u
Complexity Time complexity: O(n) Space complexity: O(1) Code
shobhit_yadav
NORMAL
2025-01-11T09:46:43.231148+00:00
2025-01-11T09:46:43.231148+00:00
24
false
# Complexity - Time complexity: $$O(n)$$ <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: $$O(1)$$ <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```java [] class Solution { public boolean canConstruct(String s, int k) { if (s.length() < k) return false; int[] c...
2
0
['Hash Table', 'String', 'Greedy', 'Counting', 'Java', 'Python3']
0
construct-k-palindrome-strings
Understand how palindromes work! Easiest possible way!
understand-how-palindromes-work-easiest-4uvuo
IntuitionAt first, this problem might seem a bit tricky if you haven’t worked with palindromes before. But the key idea here is to understand how the frequencie
pankajpatwal1224
NORMAL
2025-01-11T08:56:01.493916+00:00
2025-01-11T08:56:01.493916+00:00
12
false
# Intuition At first, this problem might seem a bit tricky if you haven’t worked with palindromes before. But the key idea here is to understand how the frequencies of characters in a string determine whether it can form a palindrome. So, what’s special about a palindrome? It’s a string that reads the same forwards an...
2
0
['Hash Table', 'String', 'Greedy', 'Counting', 'C++', 'Java', 'Python3']
0
construct-k-palindrome-strings
Easy Approach Solution Optimized Complexity 🚀
easy-approach-solution-optimized-complex-h272
IntuitionThe problem is about determining if we can construct k palindromic strings from the given string s. The key property of palindromes is that they can ha
hamza_p2
NORMAL
2025-01-11T07:16:38.250022+00:00
2025-01-11T07:16:38.250022+00:00
43
false
# Intuition The problem is about determining if we can construct k palindromic strings from the given string s. The key property of palindromes is that they can have at most one character with an odd frequency (for the center of the palindrome), and the remaining characters must appear an even number of times. # Appro...
2
0
['Java']
0
construct-k-palindrome-strings
A Dance of Odd Frequencies | One Pass Solution | Beats 100%
a-dance-of-odd-frequencies-one-pass-solu-vzsz
IntuitionTo determine if it's possible to construct exactly k palindrome strings using all the characters in s, I focused on the properties of palindromes. A pa
mahfuz2411
NORMAL
2025-01-11T07:15:51.171617+00:00
2025-01-11T07:15:51.171617+00:00
7
false
# Intuition To determine if it's possible to construct exactly `k` palindrome strings using all the characters in `s`, I focused on the properties of palindromes. A palindrome can have at most one odd-frequency character. Thus, the number of odd-frequency characters in `s` dictates the minimum number of palindromes req...
2
0
['Hash Table', 'String', 'Greedy', 'Counting', 'C++']
0
construct-k-palindrome-strings
Beats 100% || 2Approaches
beats-100-2approaches-by-sarvpreet_kaur-igg5
Complexity Time complexity: Approach 1 - O(N) Approach 2 - O(N) Code
Sarvpreet_Kaur
NORMAL
2025-01-11T07:12:16.167059+00:00
2025-01-11T07:12:16.167059+00:00
4
false
# Complexity - Time complexity: Approach 1 - O(N) Approach 2 - O(N) # Code ```cpp [] //Approach 1 class Solution { public: bool canConstruct(string s, int k) { int n = s.size(); if(k>n)return false; int odd = 0; int even = 0; vector<int>freq(26,0); for(int i=0;i<n;i+...
2
0
['Hash Table', 'String', 'Greedy', 'Counting', 'C++']
0
construct-k-palindrome-strings
Simple Java Solution - Using HashMap
simple-java-solution-using-hashmap-by-ru-w3kb
Complexity Time complexity: O(n), where n = s.length() Space complexity: O(n), where n = s.length() Code
ruch21
NORMAL
2025-01-11T07:02:17.142310+00:00
2025-01-11T07:02:17.142310+00:00
12
false
# Complexity - Time complexity: $$O(n)$$, where n = s.length() - Space complexity: $$O(n)$$, where n = s.length() # Code ```java [] class Solution { public boolean canConstruct(String s, int k) { if(s.length() < k) { return false; } HashMap<Character, Integer> map = new HashMap...
2
0
['Java']
1
construct-k-palindrome-strings
Odd Characters Assemble (But Not Too Many)!
odd-characters-assemble-but-not-too-many-6lck
IntuitionThe problem revolves around determining if a given string s can be rearranged into exactly k palindromes. A palindrome has certain properties, such as
ParthSaini1353
NORMAL
2025-01-11T06:22:37.078325+00:00
2025-01-11T06:22:37.078325+00:00
42
false
# Intuition The problem revolves around determining if a given string s can be rearranged into exactly k palindromes. A palindrome has certain properties, such as the number of odd-frequency characters. This observation drives the solution. # Approach Initial Constraints: If the length of the string s is less than ...
2
0
['C++']
0