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
find-maximum-number-of-string-pairs
[ Python ] ✅✅ Simple Python Solution Using HashMap | 95 % Faster🥳✌👍
python-simple-python-solution-using-hash-wr0i
If You like the Solution, Don\'t Forget To UpVote Me, Please UpVote! \uD83D\uDD3C\uD83D\uDE4F\n# Runtime: 52 ms, faster than 95.84% of Python3 online submission
ashok_kumar_meghvanshi
NORMAL
2023-06-28T10:46:16.813176+00:00
2023-06-28T10:46:16.813208+00:00
189
false
# If You like the Solution, Don\'t Forget To UpVote Me, Please UpVote! \uD83D\uDD3C\uD83D\uDE4F\n# Runtime: 52 ms, faster than 95.84% of Python3 online submissions for Find Maximum Number of String Pairs.\n# Memory Usage: 16.3 MB, less than 77.61% of Python3 online submissions for Find Maximum Number of String Pairs.\n...
1
0
['Hash Table', 'String', 'Python', 'Python3']
1
find-maximum-number-of-string-pairs
Easy and Understandable Code || Accepted✅✅
easy-and-understandable-code-accepted-by-a1us
Intuition\n Describe your first thoughts on how to solve this problem. \nReverse can help\n\n# Approach\n Describe your approach to solving the problem. \n1. It
Sanjeev_PU
NORMAL
2023-06-26T17:39:25.846528+00:00
2023-06-26T17:39:25.846545+00:00
92
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nReverse can help\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Iterate the loop\n2. each and every word reverse\n3. and check weather they are equal or not\n4. print result \n\n# Complexity\n- Time complexity:...
1
0
['C++']
0
find-maximum-number-of-string-pairs
easy one xd
easy-one-xd-by-shellpy03-2gox
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
shellpy03
NORMAL
2023-06-26T16:48:50.193833+00:00
2023-06-26T16:48:50.193915+00:00
90
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)$$ -->\nO(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n...
1
0
['Go']
0
find-maximum-number-of-string-pairs
easy one xd
easy-one-xd-by-shellpy03-sqb1
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
shellpy03
NORMAL
2023-06-26T16:48:48.512980+00:00
2023-06-26T16:48:48.513015+00:00
18
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)$$ -->\nO(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n...
1
0
['Go']
0
find-maximum-number-of-string-pairs
Easy Java using Map
easy-java-using-map-by-pushprajdubey-tdvl
\n\n# Code\n\nclass Solution {\n public int maximumNumberOfStringPairs(String[] words) {\n int ans = 0;\n Map<String, Integer> wordss= new Hash
pushprajdubey
NORMAL
2023-06-26T14:38:27.058196+00:00
2023-06-26T14:38:27.058220+00:00
26
false
\n\n# Code\n```\nclass Solution {\n public int maximumNumberOfStringPairs(String[] words) {\n int ans = 0;\n Map<String, Integer> wordss= new HashMap<>();\n\n for (String a : words) {\n String rWord = new StringBuilder(a).reverse().toString();\n int cnt = wordss.getOrDefaul...
1
0
['Hash Table', 'Ordered Map', 'Java']
0
find-maximum-number-of-string-pairs
Python || Beginner Friendly
python-beginner-friendly-by-sumedh0706-7zs3
Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution:\n def maximumNumberOfStringPairs(self, words: List[str]) ->
Sumedh0706
NORMAL
2023-06-25T12:02:47.543997+00:00
2023-06-25T12:02:47.544019+00:00
259
false
# Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution:\n def maximumNumberOfStringPairs(self, words: List[str]) -> int:\n cnt=0\n for i in range(len(words)):\n for j in range(i+1,len(words)):\n if words[i]==words[j][::-1]:\n ...
1
1
['Python3']
0
find-maximum-number-of-string-pairs
Go | Straightforward
go-straightforward-by-tucux-ucqo
\nfunc maximumNumberOfStringPairs(words []string) int {\n res := 0\n h := make(map[string]bool)\n for _, w := range words {\n if r := fmt.Sprint
tucux
NORMAL
2023-06-25T11:55:11.052338+00:00
2023-06-25T11:55:11.052366+00:00
61
false
```\nfunc maximumNumberOfStringPairs(words []string) int {\n res := 0\n h := make(map[string]bool)\n for _, w := range words {\n if r := fmt.Sprintf("%c%c", w[1], w[0]); h[r] {\n res++\n } else {\n h[w] = true\n }\n }\n return res\n}\n```
1
0
['Go']
0
find-maximum-number-of-string-pairs
💀NO MAP , NO SET || Using Find( ) ||🔥 Easy C++
no-map-no-set-using-find-easy-c-by-nisha-3ja4
Intuition\nSimply Pick each words Reverse it and check by using find().\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n- Dry run t
Nishant_405
NORMAL
2023-06-25T07:32:46.756287+00:00
2023-06-28T08:23:33.612709+00:00
48
false
# Intuition\nSimply Pick each words Reverse it and check by using find().\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n- Dry run the 1st Test Case.\n- pick the 1st string of the words and reverse it .\n- Befor finding the reversed string first check either 1st and 2nd letter are s...
1
0
['String', 'String Matching', 'C++']
2
find-maximum-number-of-string-pairs
Swift | Simple Set && Self-made hash solutions
swift-simple-set-self-made-hash-solution-0lgs
Simple Set\n## Complexity\n- Time complexity: $O(n)$\n- Space complexity: $O(n)$\n$n$ is words count\n\n\nclass Solution {\n func maximumNumberOfStringPairs(
VladimirTheLeet
NORMAL
2023-06-25T07:18:04.841768+00:00
2023-06-25T10:49:28.499603+00:00
56
false
# Simple Set\n## Complexity\n- Time complexity: $O(n)$\n- Space complexity: $O(n)$\n$n$ is words count\n\n```\nclass Solution {\n func maximumNumberOfStringPairs(_ words: [String]) -> Int\n {\n var wordSet: Set<String> = [], count = 0\n for word in words\n {\n if wordSet.contains(S...
1
0
['Hash Table', 'Bit Manipulation', 'Swift', 'Hash Function']
0
find-maximum-number-of-string-pairs
Easy C++ Solution | Map
easy-c-solution-map-by-_white_rabbit-y3bs
Code\n\nclass Solution {\npublic:\n int maximumNumberOfStringPairs(vector<string>& words) {\n unordered_map<string, int> mp;\n int cnt = 0;\n
_White_Rabbit_
NORMAL
2023-06-24T17:38:13.366820+00:00
2023-06-24T17:38:13.366847+00:00
76
false
# Code\n```\nclass Solution {\npublic:\n int maximumNumberOfStringPairs(vector<string>& words) {\n unordered_map<string, int> mp;\n int cnt = 0;\n for(int i=0;i<words.size();i++) {\n if(mp.find(words[i]) != mp.end()) {\n cnt++;\n mp.erase(words[i]);\n ...
1
0
['C++']
0
find-maximum-number-of-string-pairs
🔥🔥 SIMPLE C++ SOLTION 🔥WITHOUT MAP🔥🔥
simple-c-soltion-without-map-by-aman91k-c1mv
\'\'\'\nclass Solution {\npublic:\n\n int maximumNumberOfStringPairs(vector& words) {\n int n=words.size();\n int cnt=0;\n \n for
aman91k
NORMAL
2023-06-24T16:39:32.257456+00:00
2023-06-24T16:39:32.257475+00:00
307
false
\'\'\'\nclass Solution {\npublic:\n\n int maximumNumberOfStringPairs(vector<string>& words) {\n int n=words.size();\n int cnt=0;\n \n for(int i=0; i<n-1; i++){\n string s=words[i];\n for(int j=i+1; j<n; j++){\n string t=words[j];\n rever...
1
0
[]
0
find-maximum-number-of-string-pairs
c++ hash table
c-hash-table-by-lovelydays95-b9cx
c++\nclass Solution {\npublic:\n int maximumNumberOfStringPairs(vector<string>& words) {\n unordered_set<string> us;\n int res = 0;\n fo
lovelydays95
NORMAL
2023-06-24T16:17:18.209374+00:00
2023-06-24T16:17:18.209414+00:00
23
false
```c++\nclass Solution {\npublic:\n int maximumNumberOfStringPairs(vector<string>& words) {\n unordered_set<string> us;\n int res = 0;\n for(auto w : words) {\n if(us.count(w)) res += 1;\n reverse(begin(w), end(w));\n us.insert(w);\n }\n return res;...
1
0
[]
0
find-maximum-number-of-string-pairs
a few solutions
a-few-solutions-by-claytonjwong-96tm
Peform a linear scan of each string s in the input array A and count cnt reductions performed when target t is previously seen.\n\n---\n\nKotlin\n\nclass Soluti
claytonjwong
NORMAL
2023-06-24T16:08:24.554089+00:00
2023-06-24T16:17:58.164680+00:00
6
false
Peform a linear scan of each string `s` in the input array `A` and count `cnt` reductions performed when target `t` is previously `seen`.\n\n---\n\n*Kotlin*\n```\nclass Solution {\n fun maximumNumberOfStringPairs(A: Array<String>): Int {\n var cnt = 0\n var seen = mutableSetOf<String>()\n for (s...
1
0
[]
0
find-maximum-number-of-string-pairs
Using Hashing || Easy-Commented Code ✅✅
using-hashing-easy-commented-code-by-nee-sef6
Guys consider upvoting! Thanks!\n# Code\n\nclass Solution {\npublic:\n int maximumNumberOfStringPairs(vector<string>& words) {\n int n = words.size()
neergx
NORMAL
2023-06-24T16:07:51.461425+00:00
2023-06-24T16:17:33.458227+00:00
40
false
# Guys consider upvoting! Thanks!\n# Code\n```\nclass Solution {\npublic:\n int maximumNumberOfStringPairs(vector<string>& words) {\n int n = words.size();\n unordered_map<string, int> mp;\n //add words to the map\n for(int i = 0; i < n; i++){\n mp[words[i]]++;\n }\n ...
1
0
['Hash Table', 'C++']
0
maximum-candies-allocated-to-k-children
[Java/C++/Python] Binary Search with Explanation
javacpython-binary-search-with-explanati-9rcq
Intuition\nBinary search\n\n\n# Explanation\nAssume we want give each child m candies, for each pile of candies[i],\nwe can divide out at most candies[i] / m su
lee215
NORMAL
2022-04-03T04:04:28.275674+00:00
2022-04-03T06:27:51.592601+00:00
20,204
false
# **Intuition**\nBinary search\n<br>\n\n# **Explanation**\nAssume we want give each child `m` candies, for each pile of `candies[i]`,\nwe can divide out at most `candies[i] / m` sub piles with each pile `m` candies.\n\nWe can sum up all the sub piles we can divide out, then compare with the `k` children.\n\nIf `k > sum...
334
2
['C', 'Python', 'Java']
44
maximum-candies-allocated-to-k-children
✔️ Binary Search | Python | C++ | Java | JS | Go | C# | Swift
binary-search-python-c-java-by-otabek_kh-fuhi
IntuitionThis problem asks us to find the maximum number of candies we can give to each of k children. Since we can divide piles but can't merge them, and we're
otabek_kholmirzaev
NORMAL
2025-03-14T00:45:06.037586+00:00
2025-03-14T02:35:29.557697+00:00
22,228
false
# Intuition This problem asks us to find the **maximum number of candies** we can give to each of k children. Since we can divide piles but can't merge them, and we're looking for a maximum value, this is a perfect candidate for **binary search**. # Approach ## Binary Search Setup: - `left = 1`: Minimum possible can...
106
5
['Binary Search', 'Swift', 'C++', 'Java', 'Go', 'Python3', 'JavaScript', 'C#']
10
maximum-candies-allocated-to-k-children
Binary Search
binary-search-by-votrubac-myn3
Say we decide to allocate m candies. We can check if all k kids can get m candies in O(n).\n\nTherefore, we can binary-search for the maximum value m. The overa
votrubac
NORMAL
2022-04-03T04:00:27.458747+00:00
2022-04-03T04:15:34.656398+00:00
5,486
false
Say we decide to allocate `m` candies. We can check if all `k` kids can get `m` candies in O(n).\n\nTherefore, we can binary-search for the maximum value `m`. The overall runtime complexity will be O(n * log m), where `m` is maximum number of candies in a single pile (10000000).\n\nThe fact that we can split piles coul...
44
1
[]
11
maximum-candies-allocated-to-k-children
C++ Easy solution, with Explanation
c-easy-solution-with-explanation-by-rohi-21ek
Lets see about the brute force solution.\n\nWe can check for candies=1,2 and so,on until we find an answer.\n\nCan\'t we do something better,instead of linear s
Rohithch7102
NORMAL
2022-04-03T04:01:12.810796+00:00
2022-04-03T05:12:25.165288+00:00
3,622
false
Lets see about the brute force solution.\n\nWe can check for candies=1,2 and so,on until we find an answer.\n\nCan\'t we do something better,instead of linear search ?.\n\nYes, we can do **binary search.**\n \nIf we can divide the candies into piles containing x number of candies all the numbers below x,\nwill also be ...
36
0
['Binary Search', 'C']
4
maximum-candies-allocated-to-k-children
Binary Search Solution with Explanation | Java | O(n log(max(candies)))
binary-search-solution-with-explanation-e8su8
Simple Binary Search Solution | Java | O(n log(max(candies)))\n\nIdea:\nBrute force :Start with 1 candy and see if we can allocate. If yes, then check for 2 can
shaishavjogani
NORMAL
2022-04-03T04:02:17.004643+00:00
2022-04-03T04:19:44.555564+00:00
2,728
false
Simple Binary Search Solution | Java | O(n log(max(candies)))\n\n**Idea**:\nBrute force :Start with 1 candy and see if we can allocate. If yes, then check for 2 candy. \nOptimization: Instead of checking every candy at a time, why can\'t we directly check for a number to see if we can allocate that many candy. This way...
32
1
['Binary Tree', 'Java']
2
maximum-candies-allocated-to-k-children
🔥BEATS 💯 % 🎯 |✨SUPER EASY BEGINNERS 👏| JAVA | C | C++ | PYTHON| JAVASCRIPT | DART
beats-super-easy-beginners-java-c-c-pyth-1pax
IntuitionThe problem requires us to distribute candies among k children such that each child gets the same number of candies, and we want to maximize this numbe
CodeWithSparsh
NORMAL
2025-03-14T04:05:55.593710+00:00
2025-03-14T11:38:08.475856+00:00
3,380
false
![image.png](https://assets.leetcode.com/users/images/4b2aa896-28ed-4ea4-9ef0-5ba4e556a204_1741924973.6815734.png) --- # Intuition The problem requires us to distribute candies among `k` children such that each child gets the same number of candies, and we want to maximize this number. To solve this efficientl...
23
0
['Array', 'Binary Search', 'C', 'Python', 'C++', 'Java', 'Python3', 'JavaScript', 'Dart', 'Python ML']
7
maximum-candies-allocated-to-k-children
✅Range Based Binary Search 🔥| Visualization ✨| Math | Python | C++ | Java ✨
range-based-binary-search-visualization-317o1
Approach Complexity Time complexity: O(nlog(m)) Space complexity: O(1) Code
Raw_Ice
NORMAL
2025-03-14T02:19:17.183128+00:00
2025-03-14T02:19:17.183128+00:00
4,198
false
# Approach ![image.png](https://assets.leetcode.com/users/images/84844262-afdf-4d58-9e71-a35c5b36e1f9_1741918490.6617038.png) ![image.png](https://assets.leetcode.com/users/images/23254200-8e34-495b-9652-79e6318bcede_1741918627.5679643.png) # Complexity - Time complexity: $$O(nlog(m))$$ - Space complexity: $$O(1...
22
0
['Array', 'Math', 'Binary Search', 'Python', 'C++', 'Java']
3
maximum-candies-allocated-to-k-children
binary search of Koko's type||3ms Beats 99.82%
binary-search-of-kokos-type3ms-beats-998-o20y
IntuitionUse binary search. C++ & Python are doneApproachbool get_c(vector<int>& candies, long long k, int c) is defined to judge whether every child can get c
anwendeng
NORMAL
2025-03-14T02:16:15.073863+00:00
2025-03-14T05:55:46.409439+00:00
2,210
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> Use binary search. C++ & Python are done # Approach <!-- Describe your approach to solving the problem. --> `bool get_c(vector<int>& candies, long long k, int c)` is defined to judge whether every child can get c candies for k children. It...
21
0
['Binary Search', 'C++', 'Python3']
5
maximum-candies-allocated-to-k-children
Binary_Search || Intutive || Intution-Explanation
binary_search-intutive-intution-explanat-b9n3
Intution : We Know we had to distribute maximum candies , whenever face Problem in which we have to distribute and finding the maximum or minium, See the
crazy_zoker
NORMAL
2022-04-03T04:03:40.902705+00:00
2022-04-03T19:15:51.491027+00:00
1,367
false
Intution : We Know we had to distribute maximum candies , whenever face Problem in which we have to distribute and finding the maximum or minium, See the Time Complexity if Time Complexity isaround 10^4, and your answer require optimal ways then think of dp solution, if Time Complexity is around 10^5 either it ca...
19
1
[]
5
maximum-candies-allocated-to-k-children
100% faster | C++ | Python | Java | Binary Search with Logic
100-faster-c-python-java-binary-search-w-ebwe
\n\nIdea\n\n start can be taken as 1 , highest we can distribute equally is average.\n\n Use Binary Search and try to distribute the candies equal to mid, if po
TejPratap1
NORMAL
2022-04-03T04:01:54.923815+00:00
2022-04-05T15:09:56.362971+00:00
2,324
false
![image](https://assets.leetcode.com/users/images/82a7e416-2997-4676-929e-712206ab4b1a_1648961313.8131979.png)\n\n**Idea**\n\n* start can be taken as 1 , highest we can distribute equally is average.\n\n* Use Binary Search and try to distribute the candies equal to mid, if possible try to maximize it by moving on right...
14
0
['Binary Search', 'C', 'Python', 'C++', 'Java']
1
maximum-candies-allocated-to-k-children
Binary Search || Explained
binary-search-explained-by-kamisamaaaa-0wgy
Explanation :\nBinary search between [1, max(candies)] to find the result.\nif we can allocate currCandy candies to k children. then update start, if not update
kamisamaaaa
NORMAL
2022-04-03T04:00:45.326176+00:00
2022-04-03T04:39:03.739191+00:00
1,051
false
**Explanation :**\nBinary search between **[1, max(candies)]** to find the result.\n**if we can allocate currCandy candies to k children. then update start, if not update end.**\nSimilar Question : [https://leetcode.com/problems/koko-eating-bananas/]\n**Time O(Nlog(MaxC))\nSpace O(1)**\n \n \n```\nclass Solution ...
10
2
['C', 'Binary Tree']
2
maximum-candies-allocated-to-k-children
Simple and Beginner-Friendly Approach to Maximum Candies Problem
simple-and-beginner-friendly-approach-to-jwxe
IntuitionThe problem requires us to distribute candies among k children such that each child gets the maximum possible equal number of candies. Since distributi
navaneeth02
NORMAL
2025-03-14T03:41:45.088883+00:00
2025-03-14T03:43:40.453415+00:00
1,177
false
--- ## **Intuition** The problem requires us to distribute candies among `k` children such that each child gets the maximum possible equal number of candies. Since distributing `x` candies per child means checking whether we can form at least `k` groups, we need to find the **maximum possible `x`** that satisfies thi...
9
0
['Array', 'Binary Search', 'Java']
0
maximum-candies-allocated-to-k-children
Easy to understand, optimized binary search approach, beginner friendly, detail explained.
easy-to-understand-optimized-binary-sear-9zxg
\n# Approach\n1. minimum size of candy can be 1,less than 1 can not be possible.\n2. maximum size of candy can be maximum element of given candies array,greater
ysr_code
NORMAL
2023-03-07T00:54:37.801432+00:00
2023-03-07T01:12:37.742107+00:00
901
false
\n# Approach\n1. minimum size of candy can be 1,less than 1 can not be possible.\n2. maximum size of candy can be maximum element of given candies array,greater than max element can not be possible.\n3. we chose candy size by bianry search, so that we can choose in optimised time.\n4. function func give information abo...
9
0
['Binary Search', 'C++']
2
maximum-candies-allocated-to-k-children
Easy to Understand & Simplified Solution using Binary Search
easy-to-understand-simplified-solution-u-l4qp
\n# Please upvote my solution I am crying :-(\n# Intuition\n Describe your first thoughts on how to solve this problem. \nEasy to understand problem by using Bi
ShivaanjayNarula
NORMAL
2024-06-14T15:55:17.983460+00:00
2024-06-14T15:55:17.983493+00:00
303
false
\n# Please upvote my solution I am crying :-(\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nEasy to understand problem by using Binary Search in an effective way:))\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n1) Problem Breakdown:\n\nYou have a list of in...
8
0
['Array', 'Binary Search', 'C++']
1
maximum-candies-allocated-to-k-children
C++ Solution 100% Faster 💫💫💫
c-solution-100-faster-by-himanshu_52-aiv3
"""\n#define ll long long\nclass Solution {\npublic:\n int maximumCandies(vector& candies, long long k) {\n ll left=1,right=*max_element(candies.begin
himanshu_52
NORMAL
2022-04-03T04:43:32.480004+00:00
2022-04-03T05:22:41.979850+00:00
538
false
"""\n#define ll long long\nclass Solution {\npublic:\n int maximumCandies(vector<int>& candies, long long k) {\n ll left=1,right=*max_element(candies.begin(),candies.end());\n ll size=candies.size();\n ll maxi=0;\n while(left<=right){\n ll mid=left+(right-left)/2;\n ...
8
0
['Binary Search', 'C']
1
maximum-candies-allocated-to-k-children
C++ || Binary Search On Answer || Explained || O(NlogN)
c-binary-search-on-answer-explained-onlo-8h71
CONCEPT\n In these type of question first we have to find search space which is the possible set of answers which this question can have. Like in this case mini
niks07
NORMAL
2022-04-03T04:12:34.122160+00:00
2022-04-03T06:44:14.263984+00:00
639
false
**CONCEPT**\n* In these type of question first we have to find search space which is the possible set of answers which this question can have. Like in this case minimum answer can be zero and maximum can be maximum of the candies not more than that. \n* Simply apply binary search on this range [0,max] and if mid is pos...
8
1
['Binary Search', 'C']
0
maximum-candies-allocated-to-k-children
C++ Binary Search
c-binary-search-by-lzl124631x-x0or
\nSee my latest update in repo LeetCode\n\n## Solution 1. Binary Answer\n\nBinary search in range L = 1, R = max(A).\n\nFor a given M = (L + R) / 2, we test if
lzl124631x
NORMAL
2022-04-03T04:02:43.437548+00:00
2022-04-03T04:02:43.437576+00:00
856
false
\nSee my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n## Solution 1. Binary Answer\n\nBinary search in range `L = 1, R = max(A)`.\n\nFor a given `M = (L + R) / 2`, we test if we can give `M` candies to each child, which can be done by traversing the array once, taking `O(N)` time. \n\nIf ...
8
1
[]
2
maximum-candies-allocated-to-k-children
✅ One Line Solution
one-line-solution-by-mikposp-juxr
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)Code #1.1Time complexity: O(n∗log(m)). Space complex
MikPosp
NORMAL
2025-03-14T08:54:53.403069+00:00
2025-03-14T08:54:53.403069+00:00
814
false
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly) # Code #1.1 Time complexity: $$O(n*log(m))$$. Space complexity: $$O(1)$$. ```python3 class Solution: def maximumCandies(self, a: List[int], k: int) -> int: return bisect_left(range(max(a)+1),1,1,key...
7
0
['Array', 'Binary Search', 'Python', 'Python3']
2
maximum-candies-allocated-to-k-children
Maximum Candies Allocated to K Children [C++]
maximum-candies-allocated-to-k-children-ahrmp
IntuitionWe need to determine the maximum number of candies each child can receive when distributing candies among k children. The key observation is that binar
moveeeax
NORMAL
2025-03-14T07:19:19.058477+00:00
2025-03-14T07:19:19.058477+00:00
41
false
## **Intuition** We need to determine the maximum number of candies each child can receive when distributing `candies` among `k` children. The key observation is that **binary search** can be applied to find the optimal maximum number of candies each child can receive. --- ## **Approach** 1. **Check Feasibility Funct...
7
0
['C++']
0
maximum-candies-allocated-to-k-children
Beginner Friendly | 🔍 Binary Search | 🔥 Optimized Solution | ⏳ O(n log m) | 💻 Java
beginner-friendly-binary-search-optimize-fw2m
🍬 Distributing Candies Optimally using Binary SearchImagine you have different piles of candies 🍭🍬 and k children 🧑‍🤝‍🧑. Each child should get equal candies fro
himanshu7437
NORMAL
2025-03-14T01:46:14.838680+00:00
2025-03-14T20:38:15.555746+00:00
559
false
### **🍬 Distributing Candies Optimally using Binary Search** Imagine you have **different piles of candies** 🍭🍬 and **k children** 🧑‍🤝‍🧑. Each child should get **equal candies** from a **single pile**, and you can only **split piles** (not merge them). Our goal is to find **the maximum number of candies** each...
7
0
['Array', 'Two Pointers', 'Binary Search', 'Java']
2
maximum-candies-allocated-to-k-children
Beats 100% 🚀🔥| Optimized Binary Search Solution for Maximum Candies 🍬
beats-100-optimized-binary-search-soluti-yiee
Intuition 💡🤔The goal is to distribute candies 🍬 among k children 👦👧 such that each child gets the maximum possible number of candies.Instead of checking all pos
Omkrishna123
NORMAL
2025-03-14T03:55:17.798626+00:00
2025-03-14T03:57:56.981036+00:00
478
false
# Intuition 💡🤔 The goal is to distribute candies 🍬 among `k` children 👦👧 such that each child gets the **maximum possible number of candies**. Instead of checking all possible values (which is slow ❌), we recognize that the **maximum possible candies per child** lie between `1` and `sum(candies) / k`. Using *...
6
0
['Array', 'Binary Search', 'C++']
4
maximum-candies-allocated-to-k-children
[C++] accepted solution || Binary Search || faster than 100%
c-accepted-solution-binary-search-faster-eayl
\nclass Solution {\npublic:\n int maximumCandies(vector<int>& candies, long long k) {\n \n long long sum=0;\n \n int n=candies.si
soujash_mandal
NORMAL
2022-04-03T05:26:43.873500+00:00
2022-04-03T05:38:53.422596+00:00
477
false
```\nclass Solution {\npublic:\n int maximumCandies(vector<int>& candies, long long k) {\n \n long long sum=0;\n \n int n=candies.size();\n \n //calculate sum\n for(int i=0;i<n;i++)\n {\n sum+=(long long)candies[i];\n }\n \n \n ...
6
0
['C', 'Binary Tree']
1
maximum-candies-allocated-to-k-children
Easy & Detailed Approch ✅🚀 | Binary Search 🔎 | C++ | Java | Python | Js 🔥
easy-detailed-approch-binary-search-c-ja-4322
Intuition🧠 The key idea is to use Binary Search to efficiently find the maximum number of candies that can be distributed per child. Since the number of candies
himanshu_dhage
NORMAL
2025-03-14T09:33:47.962804+00:00
2025-03-14T09:33:47.962804+00:00
635
false
# Intuition 🧠 The key idea is to use **Binary Search** to efficiently find the maximum number of candies that can be distributed per child. Since the number of candies per child can range between 1 and the maximum candy count, Binary Search optimizes the search space. # Approach 🚀 Steps to solve the problem: 1. **So...
5
0
['Array', 'Binary Search', 'C++', 'Java', 'Python3', 'JavaScript']
1
maximum-candies-allocated-to-k-children
Python | Simple Binary Search | O(n log m), O(1) | Beats 100%
python-simple-binary-search-olog-m-n-o1-n6yo7
CodeComplexity Time complexity: O(log(m)∗n). The binary search has initial range from 0 to m where m is average of total candies, time is log(m). isValidSize()
2pillows
NORMAL
2025-03-14T01:39:08.711288+00:00
2025-03-14T01:44:57.104666+00:00
410
false
# Code ```python3 [] class Solution: def maximumCandies(self, candies: List[int], k: int) -> int: def isValidSize(group_candies): groups = 0 for candy in candies: groups += candy // group_candies # add groups that can be made from candy return groups >= k ...
5
0
['Binary Search', 'Python3']
1
maximum-candies-allocated-to-k-children
4 Lines | Concise | Binary Search | C++ | Python | Java | Go | JS
4-linesconcisebinary-searchc-by-sapilol-d1o1
Implementation
LeadingTheAbyss
NORMAL
2025-03-14T00:56:37.464254+00:00
2025-03-14T01:19:46.221328+00:00
923
false
# Implementation ```cpp [] class Solution { public: int maximumCandies(vector<int>& A, long long k , int l = 0 , int r = 1e7) { while(l < r){ int m = (l + r + 1)/2; long s = 0; for(auto p : A) s += p/m; if(s < k) r = m - 1; else l = m; } return l; } };...
5
0
['Array', 'Binary Search', 'Python', 'C++', 'Java', 'Go', 'JavaScript']
0
maximum-candies-allocated-to-k-children
Easy Tricky Binary Search Approach Explained Along with Code.
easy-tricky-binary-search-approach-expla-hy5v
This problem is a kind of Upper Bond problem of Binary search.\nHere we just simply have to make an binary search call by setting the min and max variables whic
adityasada
NORMAL
2022-04-03T06:11:54.861635+00:00
2022-06-29T13:35:07.461063+00:00
581
false
# This problem is a kind of Upper Bond problem of Binary search.\nHere we just simply have to make an binary search call by setting the min and max variables which is the range in which we have to be get the correct answer. Since we can give as minimum as 0 candies to k children because there are not many candies for e...
5
0
['Binary Tree', 'Java']
0
maximum-candies-allocated-to-k-children
JAVA
java-by-ayeshakhan7-l3pn
ApproachBinary Search on answerComplexity Time complexity: O(n * log(maxC)) Space complexity: O(1) Code
ayeshakhan7
NORMAL
2025-03-14T17:13:55.001202+00:00
2025-03-14T17:13:55.001202+00:00
93
false
# Approach <!-- Describe your approach to solving the problem. --> Binary Search on answer # Complexity - Time complexity: O(n * log(maxC)) <!-- 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 { p...
4
0
['Java']
0
maximum-candies-allocated-to-k-children
3 ms/8 ms C++/JS. Binary Search. Beats 100.00%
3-ms8-ms-cjs-binary-search-beats-10000-b-7ct0
ApproachBinary search for the appropriate number of candies. Check if the number of candies is appropriate using the test function.Complexity Time complexity: O
nodeforce
NORMAL
2025-03-14T11:22:55.622272+00:00
2025-03-14T11:22:55.622272+00:00
159
false
# Approach Binary search for the appropriate number of candies. Check if the number of candies is appropriate using the `test` function. ![1.png](https://assets.leetcode.com/users/images/d150e334-9ec8-41d7-a6e0-3f162401e5c8_1741951207.1881642.png) ![2.png](https://assets.leetcode.com/users/images/df997010-3309-4336-...
4
0
['Array', 'Binary Search', 'C', 'C++', 'TypeScript', 'JavaScript']
0
maximum-candies-allocated-to-k-children
✅ 🔥 Python3 | Binary search | Faster 100% ✅ 🔥
python3-binary-search-faster-100-by-sure-v189
IntuitionSince each student needs to have an equal number of candies, we divide the array into different groups, ensuring the total is divisible by the number o
Surendaar
NORMAL
2025-03-14T10:21:42.235838+00:00
2025-03-14T10:21:42.235838+00:00
148
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> Since each student needs to have an equal number of candies, we divide the array into different groups, ensuring the total is divisible by the number of students. Then, we check whether it is possible to distribute the candies accordingly. ...
4
0
['Python3']
0
maximum-candies-allocated-to-k-children
## 🔥 C++ | 🚀 Fast & Optimized | 🔍 binary-search - 🍭 greedy - 📊 array - 🎯 two-pointer
c-fast-optimized-binary-search-greedy-ar-e6wq
IntuitionThe goal is to distribute candies fairly among k children.We need to find the maximum possible number of candies per childsuch that at least k children
El_shamy
NORMAL
2025-03-14T06:44:57.246891+00:00
2025-03-14T06:44:57.246891+00:00
9
false
![Screenshot 2025-03-14 083542.png](https://assets.leetcode.com/users/images/b832d1bc-4051-49f8-a0dd-c73e168dc7a7_1741934157.1581588.png) ## Intuition ## The goal is to distribute candies fairly among `k` children. ## We need to find the **maximum possible number of candies per child** ## such that at least `k...
4
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
100% Best solution using C# (easy beginner friendly)
100-best-solution-using-c-easy-beginner-o7mju
ExplanationWe need to find the maximum number of candies that can be evenly distributed among k children. The goal is to determine the largest possible pile siz
rickeyrohit7
NORMAL
2025-03-14T05:42:29.268197+00:00
2025-03-14T05:42:29.268197+00:00
363
false
### **Explanation** We need to find the **maximum** number of candies that can be evenly distributed among **k** children. The goal is to determine the largest possible **pile size** each child can receive. #### **Intuition** - If we fix a pile size **m**, we can check how many children can get at least **m** candi...
4
1
['C++']
4
maximum-candies-allocated-to-k-children
Easy to understand || simple code || Binary Search || c++ || python || java
easy-to-understand-simple-code-binary-se-s2qt
Intuition We need to maximize the number of candies that each person can receive. By checking if a candidate number of candies per person is feasible, we can us
jayanthmarupaka29
NORMAL
2025-03-14T00:51:41.287457+00:00
2025-03-14T01:08:06.755212+00:00
489
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> - We need to maximize the number of candies that each person can receive. By checking if a candidate number of candies per person is feasible, we can use binary search to efficiently find the maximum possible value. # Approach <!-- Describe...
4
0
['Array', 'Binary Search', 'C++', 'Java', 'Python3']
2
maximum-candies-allocated-to-k-children
C++ || Binary Search || Simple Explanation
c-binary-search-simple-explanation-by-dh-qgfb
Approach\n Describe your approach to solving the problem. \nWhat comes to my mind is to check what number of candies(search space) is satisfying children.\nSo b
dhruvil2511
NORMAL
2023-03-31T07:07:34.586636+00:00
2023-04-15T08:15:42.942633+00:00
420
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nWhat comes to my mind is to check what number of candies(search space) is satisfying children.\nSo by this intuition we can find the search space. \n\nMinimum candy child can get will be 1:\nExample: [1,2,3,4] and k=5\nTotal 5 children and all of the...
4
0
['Array', 'Math', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Easy To Understand Python Solution (Binary Search)
easy-to-understand-python-solution-binar-ft1g
\nclass Solution:\n def maximumCandies(self, candies, k):\n n = len(candies)\n left = 1 # the least number of candy in each stack we can give
danielkua
NORMAL
2022-04-04T03:00:06.876607+00:00
2022-04-04T03:00:54.858099+00:00
918
false
```\nclass Solution:\n def maximumCandies(self, candies, k):\n n = len(candies)\n left = 1 # the least number of candy in each stack we can give to each student is one\n right = max(candies) # the max number of candy in each stack that we can give to each student is the maximum number in the c...
4
0
['Binary Search', 'Binary Tree', 'Python', 'Python3']
0
maximum-candies-allocated-to-k-children
1-liner Python / Ruby
1-liner-python-ruby-by-stefanpochmann-g8h6
Binary-search the smallest allocation a that\'s too large, the answer is 1 lower. Ruby still excels at this, though Python improved now that it supports a key.\
stefanpochmann
NORMAL
2022-04-03T20:20:50.914196+00:00
2022-04-03T20:22:09.211581+00:00
303
false
Binary-search the smallest allocation `a` that\'s too large, the answer is 1 lower. Ruby still excels at this, though Python improved now that it supports a `key`.\n\nRuby:\n```\ndef maximum_candies(candies, k)\n (1..10**8).bsearch { |a| candies.sum { |c| c / a } < k } - 1\nend\n```\nPython:\n\n def maximumCandies(...
4
1
['Binary Tree', 'Python', 'Ruby']
1
maximum-candies-allocated-to-k-children
[JavaScript] 2226. Maximum Candies Allocated to K Children
javascript-2226-maximum-candies-allocate-sxpd
\nWeekly Contest 287\n\n- Q1 answer\n - https://leetcode.com/problems/minimum-number-of-operations-to-convert-time/discuss/1908839/JavaScript-2224.-Minimum-Num
pgmreddy
NORMAL
2022-04-03T04:04:29.446572+00:00
2023-02-15T12:28:20.325552+00:00
441
false
\n**Weekly Contest 287**\n\n- Q1 answer\n - https://leetcode.com/problems/minimum-number-of-operations-to-convert-time/discuss/1908839/JavaScript-2224.-Minimum-Number-of-Operations-to-Convert-Time\n- Q2 answer\n - https://leetcode.com/problems/find-players-with-zero-or-one-losses/discuss/1908871/JavaScript-2225.-Find...
4
0
['JavaScript']
0
maximum-candies-allocated-to-k-children
[Binary Search🔥] | Beginner Friendly Explanation🚀 | Java, Python, C++, JavaScript
binary-search-beginner-friendly-explanat-ia0z
IntuitionWe need to distribute candies among k children such that each child gets the same number of candies. Our goal is to maximize the number of candies each
PradhumanGupta
NORMAL
2025-03-16T07:57:50.055867+00:00
2025-03-16T07:57:50.055867+00:00
17
false
# Intuition We need to **distribute candies** among `k` children such that each child gets the **same number of candies**. Our goal is to **maximize** the number of candies each child receives. Since a child can only receive **whole** candies, we can use **binary search** on the maximum possible number of candies ...
3
0
['Array', 'Binary Search', 'C++', 'Java', 'Python3', 'JavaScript']
1
maximum-candies-allocated-to-k-children
Easy BS on ANS (BEATS 100%)
easy-bs-on-ans-beats-100-by-pranavb16-vdyk
IntuitionSo , we have to find the maximum number of candies a child can get and keep in mind that he gets it from a single pile.We have to maximize the number o
pranavb16
NORMAL
2025-03-14T16:55:13.594050+00:00
2025-03-14T16:55:13.594050+00:00
55
false
# Intuition So , we have to find the maximum number of candies a child can get and keep in mind that he gets it from a single pile.We have to maximize the number of candies , so we can think of binary search on ans and the constraints also point towards the same. # Approach - Calculating the sum and dividing it by k ,...
3
0
['Binary Search', 'C++']
1
maximum-candies-allocated-to-k-children
Binary Search, O(nlogm), Easy to understand (:
binary-search-onlogm-easy-to-understand-1v9q8
Complexity Time complexity: O(nlogm) Space complexity: O(1) Code
mak2rae
NORMAL
2025-03-14T11:34:33.643360+00:00
2025-03-14T11:34:33.643360+00:00
58
false
# Complexity - Time complexity: O(nlogm) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(1) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```python3 [] class Solution: def maximumCandies(self, candies: List[int], k: int) -> int: def can_divided(c): c...
3
0
['Binary Search', 'Python3']
0
maximum-candies-allocated-to-k-children
Binary Search Approach for Maximum Candies Allocation
binary-search-approach-for-maximum-candi-45t4
IntuitionWhen distributing candies among k children, each child must receive the same amount, and the candies from a single pile cannot be merged with others. T
Samandardev02
NORMAL
2025-03-14T05:42:31.801915+00:00
2025-03-14T05:42:31.801915+00:00
68
false
## Intuition When distributing candies among `k` children, each child must receive the same amount, and the candies from a single pile cannot be merged with others. The key observation is that the maximum number of candies each child can receive must be some integer `x` such that there are at least `k` piles of size `x...
3
0
['TypeScript']
0
maximum-candies-allocated-to-k-children
Well explained solution-beats 91%
well-explained-solution-beats-91-by-mala-caml
IntuitionWe need to distribute candies such that each child gets the same maximum number of candies. The challenge is that we can split a pile but cannot merge
malayp2820
NORMAL
2025-03-14T05:30:31.929727+00:00
2025-03-14T05:30:31.929727+00:00
175
false
# Intuition We need to distribute candies such that each child gets the same maximum number of candies. The challenge is that we can split a pile but cannot merge piles together. This means the maximum number of candies a child can receive must be within the range [1, maxPileSize] (where maxPileSize is the largest pile...
3
0
['Binary Search', 'Java']
0
maximum-candies-allocated-to-k-children
Easy BinarySearch solution
easy-binarysearch-solution-by-allaboinad-cjck
Intuition We want to maximize the number of candies each child gets while ensuring that at least k children receive them. Since giving more candies means ser
allaboinadivakar
NORMAL
2025-03-14T04:37:00.353899+00:00
2025-03-14T04:37:00.353899+00:00
142
false
# Intuition 1. We want to maximize the number of candies each child gets while ensuring that at least `k` children receive them. 2. Since giving more candies means serving fewer children, we use **binary search** to efficiently find the largest valid number of candies per child. 3. For each `mid` (possible candie...
3
0
['Binary Search', 'C++']
2
maximum-candies-allocated-to-k-children
Learn this kind of Binary Search.
learn-this-kind-of-binary-search-by-josh-ou72
IntuitionApproachComplexity Time complexity: Space complexity: Code
Joshi_Y
NORMAL
2025-03-14T01:49:58.052005+00:00
2025-03-14T01:49:58.052005+00:00
183
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> search for each number of candies that k children can get equally until we get the maximum answer. # Approach <!-- Describe your approach to solving the problem. --> Use Binary Search to get the maximum number of candies that k ...
3
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Binary Search. Java | Kotlin | Python | Javascript. 100% runtime
binary-search-java-kotlin-python-javascr-w0vw
IntuitionThe task is to find the number of candies that can be taken with the same amount among k childrenApproachThis problem can be solved with brute force so
zohidjonakbarov
NORMAL
2025-03-14T01:46:23.174171+00:00
2025-03-14T01:46:23.174171+00:00
154
false
# Intuition The task is to find the number of candies that can be taken with the same amount among k children # Approach This problem can be solved with brute force solution easily by checking can k children take 1, 2, 3, 4 and so and until they cann't take it. but this is not good in Time complexity which takes $$O(n...
3
0
['Python', 'Java', 'Kotlin', 'JavaScript']
0
maximum-candies-allocated-to-k-children
Functional JavaScript 1-liner binary search by value
functional-javascript-1-liner-binary-sea-0mzf
IntuitionUse binary search up to maximum number of candies per pile, which is 107<224.Time: O(n∗log(m)) Space: O(1)
Serhii_Hrynko
NORMAL
2025-03-14T01:08:52.167912+00:00
2025-03-14T23:14:18.977069+00:00
136
false
# Intuition Use binary search up to maximum number of candies per pile, which is $$10^7 < 2^{24}$$. ``` reduce [] maximumCandies = (candies, k) => [...Array(24).keys()] .reduce((s, x) => _.sumBy(candies, y => ~~(y / x), x = s + (1 << 23 - x)) < k ? s : x, 0) ``` ``` recursion [] maximumCandies = (candies, k, $...
3
0
['Array', 'Binary Search', 'JavaScript']
1
maximum-candies-allocated-to-k-children
Simple Binary search | C++ | Well explained | Happy Holi !!!
binary-search-c-by-iitian_010u-67td
IntuitionWe have to find that maximum number, candies should be equally distributed among k children.ApproachExample : candies = {12, 34, 23, 56, 78, 45, 67, 89
iitian_010u
NORMAL
2025-03-14T00:43:04.143620+00:00
2025-03-14T01:18:15.532731+00:00
557
false
# Intuition We have to find that maximum number, candies should be equally distributed among k children. # Approach Example : candies = {12, 34, 23, 56, 78, 45, 67, 89, 90, 100} k = 15 **Step 1**: Our final answer lies in 1 to maximum element(here 100). **step 2**: check on binary search over 1 to 100 ( for this e...
3
0
['Array', 'Binary Search', 'C++']
1
maximum-candies-allocated-to-k-children
🌟🔥Best Solution in C++ || BinarySearch on Answer🔥💯
best-solution-in-c-binarysearch-on-answe-w6ir
Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\nPlease Upvote if u liked my Solution\uD83E\uDD17\n\nclass Solution {\npublic:\n
aDish_21
NORMAL
2023-02-13T18:32:56.765456+00:00
2023-02-13T18:32:56.765496+00:00
324
false
# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n**Please Upvote if u liked my Solution**\uD83E\uDD17\n```\nclass Solution {\npublic:\n bool occurrences(int x,vector<int>& candies,long k){\n long ans=0;\n for(auto it:candies){\n ans+=it/x;\n if(an...
3
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Concise Binary Search | C++
concise-binary-search-c-by-tusharbhart-pj53
\nclass Solution {\n bool good(int x, vector<int> &c, long long k) {\n long long cnt = 0;\n for(int i : c) cnt += i / x;\n return cnt <
TusharBhart
NORMAL
2022-12-27T15:56:44.990616+00:00
2022-12-27T15:56:44.990661+00:00
800
false
```\nclass Solution {\n bool good(int x, vector<int> &c, long long k) {\n long long cnt = 0;\n for(int i : c) cnt += i / x;\n return cnt < k ? false : true;\n }\npublic:\n int maximumCandies(vector<int>& candies, long long k) {\n int s = 1, e = 1e9, ans = INT_MIN;\n while(s <...
3
0
['Binary Search', 'C++']
1
maximum-candies-allocated-to-k-children
Java solution | using binary search
java-solution-using-binary-search-by-kav-e0gr
\nprivate boolean isPossible(int[] candies,int max,long k){\n long sum = 0;\n for(int i = 0; i<candies.length;i++){\n sum += (candies[i
Kavya_Yadav
NORMAL
2022-08-16T15:01:31.313106+00:00
2022-08-16T15:01:31.313138+00:00
341
false
```\nprivate boolean isPossible(int[] candies,int max,long k){\n long sum = 0;\n for(int i = 0; i<candies.length;i++){\n sum += (candies[i]/max);\n }\n if(sum>=k){\n return true;\n }\n return false;\n }\n public int maximumCandies(int[] candies, long...
3
0
['Binary Tree', 'Java']
0
maximum-candies-allocated-to-k-children
python | easy to understand | 50% faster
python-easy-to-understand-50-faster-by-r-4bxr
\nclass Solution:\n """\n approach: \n the problem can be tackled using binary search \n max_candies that can be allocated to children = max(candies
rktayal
NORMAL
2022-04-23T18:06:43.646888+00:00
2022-04-23T18:06:43.646935+00:00
337
false
```\nclass Solution:\n """\n approach: \n the problem can be tackled using binary search \n max_candies that can be allocated to children = max(candies)\n min_candies that can be allocated to children = 1\n \n we will apply binary search on finding the optimal values of candies that can be\n dis...
3
0
['Binary Tree', 'Python']
0
maximum-candies-allocated-to-k-children
C++|Discrete Binary search
cdiscrete-binary-search-by-ajai_cr_7-8jaj
\nclass Solution {\npublic:\n bool check(long val,vector<int>&candies,long k){\n long sum = 0;\n for(auto it : candies){\n sum += (i
ajai_cr_7
NORMAL
2022-04-18T09:11:30.022315+00:00
2022-04-18T09:11:30.022371+00:00
210
false
```\nclass Solution {\npublic:\n bool check(long val,vector<int>&candies,long k){\n long sum = 0;\n for(auto it : candies){\n sum += (it/val);\n }\n return sum >= k;\n }\n int maximumCandies(vector<int>& candies, long long k) {\n long start = 1, end = 1e9;\n ...
3
0
['C', 'Binary Tree']
1
maximum-candies-allocated-to-k-children
C++ | O(N) solution with explanation | Binary Search
c-on-solution-with-explanation-binary-se-ldrq
Code:\nTC: O(N), SC: O(1)\n\nclass Solution {\npublic:\n \n bool isPossible(vector<int>& candies, int mid, long long k)\n {\n //it contains pile
Yash2arma
NORMAL
2022-04-03T08:34:16.329972+00:00
2022-04-03T08:34:16.330008+00:00
345
false
**Code:**\n**TC: O(N), SC: O(1)**\n```\nclass Solution {\npublic:\n \n bool isPossible(vector<int>& candies, int mid, long long k)\n {\n //it contains piles of candies that tells whether we can distribute or not assign to children equally \n long count=0;\n for(auto it:candies)\n {\...
3
0
['C', 'Binary Tree', 'C++']
2
maximum-candies-allocated-to-k-children
Easy Understandable JAVA ACCEPTED
easy-understandable-java-accepted-by-adi-yy0r
\nclass Solution {\n public static int maximumCandies(int[] arr, long k) {\n\t\tArrays.sort(arr);\n\t\tint low = 1;\n\t\tint right = arr[arr.length - 1];\n\t
Aditya_jain_2584550188
NORMAL
2022-04-03T06:06:48.242917+00:00
2022-04-03T06:08:20.007179+00:00
254
false
```\nclass Solution {\n public static int maximumCandies(int[] arr, long k) {\n\t\tArrays.sort(arr);\n\t\tint low = 1;\n\t\tint right = arr[arr.length - 1];\n\t\twhile (low <= right) {\n\t\t\tint mid = (right - low) / 2 + low;\n\t\t\tif (helper(arr, k, mid)) {\n\t\t\t\tlow = mid + 1;\n\t\t\t} else {\n\t\t\t\tright =...
3
0
['Binary Search', 'Java']
0
maximum-candies-allocated-to-k-children
Intuition behind Binary Search on Answers
intuition-behind-binary-search-on-answer-in8m
\n\nWhen there are multiple answers that are valid but we need to find the maximum possible valid answer or minimum possible valid answer then we can use binary
bitmasker
NORMAL
2022-04-03T04:32:16.641424+00:00
2022-04-03T04:36:06.830181+00:00
168
false
<br>\n\n`When there are multiple answers that are valid but we need to find the maximum possible valid answer or minimum possible valid answer then we can use binary search on answers.`\n\n**How does it work ?**\n\nin this problem we know that minimum number of candies that we can allocate is 0 and maximum is max(candi...
3
0
['Binary Search', 'C', 'Binary Tree']
1
maximum-candies-allocated-to-k-children
C++ || BINARY SEARCH
c-binary-search-by-vineet_raosahab-4jxv
\nclass Solution {\npublic:\n \n int maximumCandies(vector<int>& candies, long long k) {\n long long l=1,h=0;\n for(int& t:candies)\n
VineetKumar2023
NORMAL
2022-04-03T04:16:47.337631+00:00
2022-04-03T04:16:47.337677+00:00
190
false
```\nclass Solution {\npublic:\n \n int maximumCandies(vector<int>& candies, long long k) {\n long long l=1,h=0;\n for(int& t:candies)\n h+=t;\n int ans=0;\n while(l<=h)\n {\n long long mid=l+(h-l)/2;\n long long val=0;\n for(auto t:ca...
3
0
['Binary Search', 'C', 'C++']
0
maximum-candies-allocated-to-k-children
[C++] || Binary search || fastest
c-binary-search-fastest-by-4byx-zzw0
\nclass Solution {\npublic:\n long long solve(vector<int>& c , long long mid){\n int n = c.size();\n long long cnt = 0;\n for(int i = n-
4byx
NORMAL
2022-04-03T04:01:33.339234+00:00
2022-04-03T04:52:23.843008+00:00
235
false
```\nclass Solution {\npublic:\n long long solve(vector<int>& c , long long mid){\n int n = c.size();\n long long cnt = 0;\n for(int i = n-1 ; i >= 0 ; i--){\n cnt += (c[i]/mid);\n }\n return cnt;\n }\n int maximumCandies(vector<int>& c, long long k) {\n lon...
3
0
['C']
1
maximum-candies-allocated-to-k-children
⭐Python Solution with Binary Search Explained
python-solution-with-binary-search-expla-itm0
\nclass Solution:\n def maximumCandies(self, candies: List[int], k: int) -> int:\n # The lower bound is 1 and higher bound is maximum value from candi
ancoderr
NORMAL
2022-04-03T04:01:03.076763+00:00
2022-04-03T04:04:47.792495+00:00
370
false
```\nclass Solution:\n def maximumCandies(self, candies: List[int], k: int) -> int:\n # The lower bound is 1 and higher bound is maximum value from candies. \n lo, hi = 1, max(candies)\n # This higher bound is not generally possible except for cases like candies = [5,5,5,5] & k = 4\n res ...
3
1
['Binary Tree', 'Python', 'Python3']
1
maximum-candies-allocated-to-k-children
✅✅ Binary Search || Beginner Friendly || Easy Solution
binary-search-beginner-friendly-easy-sol-d0c4
Intuition We need to distribute candies among k children such that each child gets the same maximum number of candies. The goal is to maximize this number. Inst
Karan_Aggarwal
NORMAL
2025-03-16T12:51:07.463223+00:00
2025-03-16T12:51:07.463223+00:00
6
false
# **Intuition** - We need to distribute `candies` among `k` children such that **each child gets the same maximum number of candies**. - The goal is to **maximize** this number. - Instead of distributing candies one by one, we **binary search** for the maximum number of candies each child can receive. # **Approach** ...
2
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Easy Solution 👍 | Beginner Friendly 😊| Binary Search 🔥| 100% beats ✅ | 0(1) SC🔥
easy-solution-beginner-friendly-binary-s-rkts
IntuitionThis question is almost similar to the famous "Aggressive Cow" problem where we pick up random numbers from the range and check how many cows can be di
SayanX
NORMAL
2025-03-14T19:08:07.791369+00:00
2025-03-14T19:13:23.931120+00:00
26
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> This question is almost similar to the famous "Aggressive Cow" problem where we pick up random numbers from the range and check how many cows can be distributed. # Approach <!-- Describe your approach to solving the problem. --> see the ma...
2
0
['C++']
2
maximum-candies-allocated-to-k-children
Sol
sol-by-ansh1707-2yb1
Code
Ansh1707
NORMAL
2025-03-14T18:08:19.843610+00:00
2025-03-14T18:08:19.843610+00:00
6
false
# Code ```python [] class Solution(object): def maximumCandies(self, candies, k): """ :type candies: List[int] :type k: int :rtype: int """ if sum(candies) < k: return 0 low, high = 1, max(candies) res = 0 while low <=...
2
0
['Python']
0
maximum-candies-allocated-to-k-children
🔍 Binary Search on probable answer space || Easy solution
binary-search-on-probable-answer-space-e-o6sd
IntuitionThe minimum candy a child can get is 1, and the maximum is the largest pile size. We can use binary search on the answer to find the maximum number of
AlgoZen01
NORMAL
2025-03-14T15:18:35.515862+00:00
2025-03-14T15:18:35.515862+00:00
10
false
# Intuition The minimum candy a child can get is 1, and the maximum is the largest pile size. We can use binary search on the answer to find the maximum number of candies that can be allocated to k children. # Approach - Binary Search between 1 and max(candies). - Helper Function counts how many children can get mid c...
2
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Simple Solution using binary search 92% beats 🔥🔥| java
simple-solution-using-binary-search-92-b-3a7g
IntuitionApproachComplexity Time complexity: Space complexity: Code
harshit_4149
NORMAL
2025-03-14T13:40:32.520085+00:00
2025-03-14T13:40:32.520085+00:00
15
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 `...
2
0
['Binary Search', 'Java']
0
maximum-candies-allocated-to-k-children
Python✅✅ | Simplest approach🚀🚀
python-simplest-approach-by-aayu_t-r8v2
Code
aayu_t
NORMAL
2025-03-14T13:25:38.993191+00:00
2025-03-14T13:25:38.993191+00:00
12
false
# Code ```python3 [] class Solution: def maximumCandies(self, candies: List[int], k: int) -> int: n = len(candies) def check(mid): cnt = sum(candy // mid for candy in candies) return cnt >= k l, h = 1, sum(candies) ans = 0 while l <= h: ...
2
0
['Array', 'Binary Search', 'Python3']
0
maximum-candies-allocated-to-k-children
✅ 100% 🧊 10 ms | Binary Search & optimizations
100-10-ms-binary-search-optimizations-by-3cmv
Please Upvote 🔝 Appreciations!CodeComplexity Time complexity: O( n log n ) Space complexity: O( 1 )
sunnoca
NORMAL
2025-03-14T09:56:48.205040+00:00
2025-03-14T10:00:16.465454+00:00
83
false
# Please Upvote 🔝 Appreciations! ![image.png](https://assets.leetcode.com/users/images/7c3830ed-e09a-4d72-9f65-945ac5a00895_1741946098.795267.png) # Code ``` kotlin [] class Solution { fun maximumCandies(candies: IntArray, k: Long): Int { var right = (candies.sumOf { it.toLong() } / k).toInt() var ...
2
0
['Array', 'Math', 'Binary Search', 'Java', 'Kotlin']
1
maximum-candies-allocated-to-k-children
Simple and Beginner-Friendly Binary Search | Python | java | cpp || LC : 2226 || (❁´◡`❁)✨
simple-and-beginner-friendly-binary-sear-cgod
Intuition : We need to maximize the candy piece size that can be distributed equally among k children. Using binary search, we find the largest possible size mi
__aj__17
NORMAL
2025-03-14T08:23:08.111274+00:00
2025-03-14T08:23:08.111274+00:00
119
false
# Intuition : We need to maximize the candy piece size that can be distributed equally among k children. Using binary search, we find the largest possible size mid such that the total number of pieces (sum(candies[i] / mid)) is at least k. <!-- Describe your first thoughts on how to solve this problem. --> # Approach ...
2
0
['Array', 'Binary Search', 'C++', 'Java', 'Python3']
0
maximum-candies-allocated-to-k-children
[ Kotlin | Java | C++ | Python ] Simple Binary Search solution, detailed explanation
kotlin-java-c-python-simple-binary-searc-h8h6
IntuitionThis is a classic application of binary search on the answer space. The problem asks us to find the maximum number of candies that can be allocated to
DmitryNekrasov
NORMAL
2025-03-14T07:13:36.464925+00:00
2025-03-14T07:13:36.464925+00:00
82
false
# Intuition This is a classic application of binary search on the answer space. The problem asks us to find the maximum number of candies that can be allocated to each child, where: 1. Each child must get the same number of candies 2. Candies can only be taken from a single pile per child 3. Piles can be divided but no...
2
0
['Array', 'Binary Search', 'Python', 'C++', 'Java', 'Python3', 'Kotlin']
0
maximum-candies-allocated-to-k-children
🔥Beats 100%🔥Easy & Visual Explaination | 18ms | Beginner Level | Binary Search Approach
beats-100easy-visual-explaination-18ms-b-u6mx
:) Problem UnderstandingYou have an array candies, where each element represents a pile of candies. You need to distribute these candies among k children equall
AryanDarji07
NORMAL
2025-03-14T06:58:12.953776+00:00
2025-03-14T06:58:12.953776+00:00
233
false
# :) Problem Understanding You have an array `candies`, where each element represents a pile of candies. You need to distribute these candies among `k` children equally, ensuring that each child gets the same number of candies. You can split the piles but cannot merge them together. --- # :) Binary Search Solution (...
2
0
['Binary Search', 'C', 'Python', 'C++', 'Java', 'Go', 'TypeScript', 'Ruby', 'JavaScript', 'C#']
1
maximum-candies-allocated-to-k-children
Maximum Candies Distribution - Binary Search (Easiest and Optimal approach)
maximum-candies-distribution-binary-sear-e4c8
IntuitionThe problem boils down to distributing candies into k piles as evenly as possible, ensuring each child gets the maximum number of candies. The intuitio
Sharvesh_Kanagaraj
NORMAL
2025-03-14T06:27:38.472553+00:00
2025-03-14T06:36:19.231017+00:00
10
false
# Intuition The problem boils down to distributing candies into k piles as evenly as possible, ensuring each child gets the maximum number of candies. The intuition here is to treat the problem like a "binary search on answers" — where the answer is the maximum number of candies a child can get. We guess a possible sol...
2
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Have some candies :) 🍭🍭
have-some-candies-by-yojitkataria-oj9h
THINKcandies = [5, 8, 6], k = 3TC: Binary search range: O(log(max(candies))) Each iteration: O(n) to compute count Total complexity: O(n log m), where m = max(c
YOJITKATARIA
NORMAL
2025-03-14T06:16:57.657370+00:00
2025-03-14T06:16:57.657370+00:00
131
false
# THINK candies = [5, 8, 6], k = 3 ![image.png](https://assets.leetcode.com/users/images/2d7b6806-b32e-4274-9550-addb4233d5a9_1741932676.6579456.png) # TC: - Binary search range: O(log(max(candies))) - Each iteration: O(n) to compute count - Total complexity: O(n log m), where m = max(candies) - This is an efficien...
2
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
C# Solution for Maximum Candies Allocated To K Children Problem
c-solution-for-maximum-candies-allocated-l0ao
IntuitionWe need to distribute candies among k children such that: Each child gets the same number of candies. A child can receive candies only from one pile. S
Aman_Raj_Sinha
NORMAL
2025-03-14T06:01:39.863595+00:00
2025-03-14T06:01:39.863595+00:00
79
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> We need to distribute candies among k children such that: 1. Each child gets the same number of candies. 2. A child can receive candies only from one pile. 3. Some piles may go unused. 4. The goal is to maximize the number of candies each c...
2
0
['C#']
0
maximum-candies-allocated-to-k-children
🚀Simple Python Solution | Binary Search Approach 💡
simple-python-solution-binary-search-app-edsr
IntuitionWe need to distribute candies as evenly as possible among k children while maximizing the number of candies each child gets. Since we are dividing cand
smit-panchal
NORMAL
2025-03-14T05:55:08.049778+00:00
2025-03-14T06:02:04.277161+00:00
43
false
# Intuition We need to distribute candies as evenly as possible among k children while maximizing the number of candies each child gets. Since we are dividing candies from different piles, we can use binary search to efficiently find the maximum number of candies each child can receive. <!-- Describe your first thought...
2
0
['Binary Search', 'Python3']
0
maximum-candies-allocated-to-k-children
✅🚀 easy binary search code with explanation in all language
easy-understandable-code-with-explanatio-b1h1
exampleComplexityCode
thakur_saheb
NORMAL
2025-03-14T05:47:03.736900+00:00
2025-03-14T05:50:01.499371+00:00
68
false
![image.png](https://assets.leetcode.com/users/images/5f703938-faa7-48f5-8f32-9c229a441dcb_1741930962.771123.png) # example ![image.png](https://assets.leetcode.com/users/images/6c74d9b1-7f22-4efd-b111-820271e4d294_1741930997.3041086.png) ![image.png](https://assets.leetcode.com/users/images/d6d281ec-a925-4c7d-82da-...
2
0
['C', 'Python', 'C++', 'Java', 'Go', 'TypeScript', 'Rust', 'Ruby', 'JavaScript', 'C#']
0
maximum-candies-allocated-to-k-children
Easy Python Code
easy-python-code-by-akshaya0108-xvyp
Code
Akshaya0108
NORMAL
2025-03-14T05:32:37.786904+00:00
2025-03-14T05:32:37.786904+00:00
88
false
# Code ```python3 [] class Solution: def maximumCandies(self, candies: List[int], k: int) -> int: if sum(candies) < k: return 0 left, right = 1, max(candies) result = 0 while left <= right: mid = (left + right) // 2 count = sum(c // mid for c i...
2
0
['Python3']
0
maximum-candies-allocated-to-k-children
Maximum Candies Distribution Using Binary Search 🚀
maximum-candies-distribution-using-binar-fw1i
IntuitionWe need to determine the maximum number of candies each child can receive, given that we have k children and an array of candies distributed in differe
2u2CuogQQc
NORMAL
2025-03-14T04:28:56.178319+00:00
2025-03-14T04:28:56.178319+00:00
5
false
# Intuition We need to determine the maximum number of candies each child can receive, given that we have k children and an array of candies distributed in different piles. The key observation is that if x candies per child is possible, then any value less than x is also possible. This suggests a binary search approach...
2
0
['Java']
0
maximum-candies-allocated-to-k-children
Easy code | Must try | code in java
easy-code-must-try-code-in-java-by-notad-o7sx
IntuitionApproachComplexity Time complexity: Space complexity: Code
NotAditya09
NORMAL
2025-03-14T03:59:11.595703+00:00
2025-03-14T03:59:11.595703+00:00
135
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 `...
2
0
['Java']
0
maximum-candies-allocated-to-k-children
Simple Binary Search Solution
simple-binary-search-solution-by-aadithy-prtx
CodeThank you, aadithya18.
aadithya18
NORMAL
2025-03-14T02:34:27.228806+00:00
2025-03-14T02:34:27.228806+00:00
78
false
# Code ```cpp [] class Solution { public: bool fun(vector<int>& candies, int mi, long long &k){ long long r = 0; for(int i = 0; i<candies.size();i++){ r += (candies[i]/mi); } return r >= k; } int maximumCandies(vector<int>& candies, long long k) { int mx...
2
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
The Simplest Approach Towards Better Solution
the-simplest-approach-towards-better-sol-2rqj
🍬 Problem Statement: Maximum Candies Allocation You have an array of candies 🏗️, where each pile has some number of candies. You need to distribute the candies
DS_Sijwali
NORMAL
2025-03-14T01:51:53.508813+00:00
2025-03-14T01:51:53.508813+00:00
111
false
## **🍬 Problem Statement: Maximum Candies Allocation** - You have an array of **candies** 🏗️, where each pile has some number of candies. - You need to distribute the candies among **k children** 👶 such that: - Each child gets the **same** number of candies 🍫. - All candies taken by a child must come from a si...
2
0
['Binary Search', 'Java']
0
maximum-candies-allocated-to-k-children
Beat 100% ✅ - Maximum Candies with Binary Search
beat-100-maximum-candies-with-binary-sea-ldkv
CodePlease Up Vote ⬆️⬆️ If it is helpfulApproachThis approach uses binary search to efficiently determine the maximum number of candies that can be distributed
lehieu99666
NORMAL
2025-03-14T00:37:39.260135+00:00
2025-03-14T00:37:39.260135+00:00
226
false
# Code ```python3 [] class Solution: def maximumCandies(self, candies: List[int], k: int) -> int: # Early check: if total candies is less than k, return 0 total = sum(candies) if total < k: return 0 # Binary search for the maximum possible allocation left...
2
0
['Array', 'Binary Search', 'Python3']
0
maximum-candies-allocated-to-k-children
🍬 Maximum Candies Allocated to K Children 🍬 | 🎯 Easy Binary Search Explaination! 🚀
maximum-candies-allocated-to-k-children-7n5ml
IntuitionThe problem requires us to distribute candies among k children such that each child receives the maximum possible equal number of candies. The challeng
akshatksingh25
NORMAL
2025-03-01T10:15:21.911912+00:00
2025-03-01T10:15:21.911912+00:00
94
false
# Intuition The problem requires us to distribute candies among `k` children such that each child receives the maximum possible **equal** number of candies. The challenge is to determine this maximum number efficiently. To solve this, consider the following observations: - If we know the number of candies each child s...
1
0
['Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
One line | Python | Binary Search
one-line-python-binary-search-by-popzkk-h9i8
Approach\nNothing special. Posting here to share a simple one-liner using bisect.\n\n# Code\npython3\nclass Solution:\n def maximumCandies(self, candies: Lis
popzkk
NORMAL
2024-03-29T00:53:58.847846+00:00
2024-03-29T00:53:58.847870+00:00
295
false
# Approach\nNothing special. Posting here to share a simple one-liner using `bisect`.\n\n# Code\n```python3\nclass Solution:\n def maximumCandies(self, candies: List[int], k: int) -> int:\n return bisect_left(range(1, sum(candies) // k + 1), True, key=lambda c: sum(x // c for x in candies) < k)\n```
2
0
['Binary Search', 'Python3']
0
maximum-candies-allocated-to-k-children
Easy C++ Solution | Step-wise Approach | Beats 97.73% | Binary Search
easy-c-solution-step-wise-approach-beats-rhwk
Intuition and Approach\n\nThe problem involves distributing candies into piles such that each pile contains a certain number of candies. The goal is to maximize
darkaadityaa
NORMAL
2024-02-08T20:34:34.034151+00:00
2024-02-08T20:34:34.034181+00:00
31
false
# Intuition and Approach\n\nThe problem involves distributing candies into piles such that each pile contains a certain number of candies. The goal is to maximize the number of candies in each pile while ensuring that at least k piles are formed.\n\n-- The maximum candies a person can get would be the maximum element p...
2
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Easy understandable C++ solution || Binary search on answers approach
easy-understandable-c-solution-binary-se-096g
\n\nclass Solution {\npublic:\n bool isPossible(vector<int>& candies, int mid, long long k){\n long long count = 0;\n int n = candies.size();\n
bharathgowda29
NORMAL
2023-12-30T19:55:32.849401+00:00
2023-12-30T19:55:32.849433+00:00
419
false
\n```\nclass Solution {\npublic:\n bool isPossible(vector<int>& candies, int mid, long long k){\n long long count = 0;\n int n = candies.size();\n for(int i=0; i<n; i++){\n count += candies[i]/mid;\n }\n\n if(count < k){\n return false;\n }\n\n r...
2
0
['Array', 'Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Binary Search | C++ Easy | O(N log K) | Detailed Explanation of each step
binary-search-c-easy-on-log-k-detailed-e-d4qv
Intuition\n Describe your first thoughts on how to solve this problem. \nTo solve this problem, you can use binary search to efficiently find the maximum number
leftrecursion
NORMAL
2023-12-17T12:52:14.266012+00:00
2023-12-17T12:52:14.266040+00:00
203
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo solve this problem, you can use binary search to efficiently find the maximum number of candies that can be allocated to each child. The key observation is that if it\'s possible to allocate mid candies to each child, then it\'s also p...
2
0
['Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
Simple Binary Search
simple-binary-search-by-juwnl-usak
Intuition\nBinary Search and check condition every search\n\n# Approach\nBinary Search\n\n# Complexity\n- Time complexity:\nO(n*logn)\n\n- Space complexity:\nO(
JuWnL
NORMAL
2023-10-24T05:50:40.807585+00:00
2023-10-24T05:50:40.807603+00:00
257
false
# Intuition\nBinary Search and check condition every search\n\n# Approach\nBinary Search\n\n# Complexity\n- Time complexity:\n$$O(n*logn)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n``` python\nclass Solution:\n def maximumCandies(self, candies: List[int], k: int) -> int:\n def check(candyPerPile):\n ...
2
0
['Binary Search', 'Python3']
0
maximum-candies-allocated-to-k-children
C++ solution using Binary Search
c-solution-using-binary-search-by-vasant-x4tg
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n# Approach\n Describe your approach to solving the problem. \nbinary search approac
vasanthkokkiligadda
NORMAL
2023-09-16T18:00:15.885000+00:00
2023-09-16T18:00:15.885018+00:00
12
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nbinary search approach similar to koko eating bananas\n\n# Complexity\n- Time complexity:\n- O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Spa...
2
0
['C++']
0
maximum-candies-allocated-to-k-children
C++ || [Binary Search]
c-binary-search-by-shivamr066-tp82
Code\n\nclass Solution {\npublic:\n int maximumCandies(vector<int>& arr, long long k) {\n long long int result = 0 ;\n long long int low =
shivamR066
NORMAL
2023-08-18T06:38:35.501049+00:00
2023-08-18T06:38:35.501077+00:00
320
false
# Code\n```\nclass Solution {\npublic:\n int maximumCandies(vector<int>& arr, long long k) {\n long long int result = 0 ;\n long long int low = 1;\n auto it = max_element(arr.begin() , arr.end());\n long long int high = (long long int)(*it);\n int n = arr.size();\n ...
2
0
['C++']
0