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
longest-unequal-adjacent-groups-subsequence-ii
Longest subsequence adjacent groups subsequence || Time complexity O(n * m^2) || using recursion
longest-subsequence-adjacent-groups-subs-blat
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
prajwal13r
NORMAL
2023-12-09T11:25:14.447018+00:00
2023-12-09T11:25:14.447045+00:00
5
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: O(n * m^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n * m)\n<!-- Add your space complexity he...
0
0
['Hash Table', 'Recursion', 'Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
Python Medium
python-medium-by-lucasschnee-rqbq
\nclass Solution:\n def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:\n N = len(words)\n\n \n
lucasschnee
NORMAL
2023-11-23T01:06:12.314791+00:00
2023-11-23T01:06:12.314809+00:00
4
false
```\nclass Solution:\n def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:\n N = len(words)\n\n \n best = 0\n\n def good(l, r):\n counter = 0\n for i in range(len(words[l])):\n if words[l][i] != words[r][i]...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
Easy Python Solution
easy-python-solution-by-sb012-a19f
Code\n\nclass Solution:\n def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:\n\n def wordCondition(w1,
sb012
NORMAL
2023-11-14T20:02:48.957652+00:00
2023-11-14T20:02:48.957680+00:00
7
false
# Code\n```\nclass Solution:\n def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:\n\n def wordCondition(w1, w2):\n if len(w1) != len(w2): return False\n if sum(a != b for a, b in zip(w1, w2)) == 1: return True\n return False\n\n ...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
DP+HashMap to remember all previous words with the same length
dphashmap-to-remember-all-previous-words-1e3r
Intuition\nTry to remember past results and only search the relevant previous subsequences.\n\n# Approach\nThe current length and last words of each subsequence
flyfish
NORMAL
2023-11-08T03:02:09.235784+00:00
2023-11-08T03:04:51.220167+00:00
3
false
# Intuition\nTry to remember past results and only search the relevant previous subsequences.\n\n# Approach\nThe current length and last words of each subsequence should be recorded, not only the length.\n\nBackfill last words to generate a reverse list or use addLast.\n\n# Complexity\n- Time complexity:\n<!-- Add your...
0
0
['Java']
0
longest-unequal-adjacent-groups-subsequence-ii
Longest Unequal Adjacent Groups Subsequence II
longest-unequal-adjacent-groups-subseque-ex40
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
Vk_2005_mr
NORMAL
2023-11-02T19:30:57.917084+00:00
2023-11-02T19:30:57.917109+00:00
6
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)$$ --...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
🔥 C++ Solution || Top - Down DP approach || Faster and Easy to understand
c-solution-top-down-dp-approach-faster-a-oxhq
\n\n# Code\n\nclass Solution {\npublic:\n int hammingDistance(string& s1,string& s2){\n int n = s1.size();\n\n int d = 0;\n for(int i=0;
ravi_verma786
NORMAL
2023-11-01T11:00:20.354709+00:00
2023-11-01T11:00:20.354733+00:00
4
false
\n\n# Code\n```\nclass Solution {\npublic:\n int hammingDistance(string& s1,string& s2){\n int n = s1.size();\n\n int d = 0;\n for(int i=0;i<n;i++){\n d += (s1[i] != s2[i]);\n\n if(d > 1) break;\n }\n\n return d;\n }\n\n vector<string> getWordsInLongestS...
0
0
['String', 'Dynamic Programming', 'C++']
0
longest-unequal-adjacent-groups-subsequence-ii
DP with optimal answer storage.
dp-with-optimal-answer-storage-by-rahul_-82w9
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
rahul_bhaiya
NORMAL
2023-10-30T10:38:37.058278+00:00
2023-10-30T10:38:37.058298+00:00
3
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)$$ --...
0
0
['C++']
0
longest-unequal-adjacent-groups-subsequence-ii
Using dp O(n^2) solution
using-dp-on2-solution-by-zaid_2034-hr7w
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nsimple dp\n\n# Complexity\n- Time complexity:\nO(n^2)\n- Space complexity
Zaid_2034
NORMAL
2023-10-26T12:17:04.974606+00:00
2023-10-26T12:17:04.974627+00:00
4
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nsimple dp\n\n# Complexity\n- Time complexity:\nO(n^2)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n bool hamm(string a,string b){\n if(a.le...
0
0
['C++']
0
longest-unequal-adjacent-groups-subsequence-ii
DP (LIS) problem
dp-lis-problem-by-ar_it_is-utob
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
ar_it_is
NORMAL
2023-10-26T10:23:15.740176+00:00
2023-10-26T10:23:15.740206+00:00
4
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)$$ --...
0
0
['Dynamic Programming', 'C++']
0
longest-unequal-adjacent-groups-subsequence-ii
Simple (LIS Approach)
simple-lis-approach-by-ajaybunty5847-3cxd
Intuition\nFollow the LIS Approach and then store the indices of the longest subsequence in prev array backtrack the prev array and store it in a list and rever
Ajaybunty5847
NORMAL
2023-10-26T06:32:52.680708+00:00
2023-10-26T06:32:52.680740+00:00
2
false
# Intuition\nFollow the LIS Approach and then store the indices of the longest subsequence in $$prev$$ array backtrack the $$prev$$ array and store it in a list and reverse the list and return it.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nIf we know how to print the LIS (Longes...
0
0
['Java']
0
longest-unequal-adjacent-groups-subsequence-ii
Essentially LIS | DP
essentially-lis-dp-by-cold_coffee-7sgh
Intuition\n Describe your first thoughts on how to solve this problem. \nKeep track of longest subsequence fulfillling group and distance conditions. A parent a
cold_coffee
NORMAL
2023-10-24T22:10:11.831792+00:00
2023-10-24T22:10:11.831824+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nKeep track of longest subsequence fulfillling group and distance conditions. A parent array is maintained to construct\nthe solution once longest subsequence is determined.\nSo essentially a LIS problem disguised as this convoluted monstr...
0
0
['C++']
0
longest-unequal-adjacent-groups-subsequence-ii
Brutal force but very efficient
brutal-force-but-very-efficient-by-fredr-dmft
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
Fredrick_LI
NORMAL
2023-10-24T09:39:43.027760+00:00
2023-10-24T09:39:43.027777+00:00
6
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)$$ --...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
Backwards DP
backwards-dp-by-guobao2-76dn
Intuition\nThe trick is to sort the words by length. Since it has corresponding groups I create a new array of pairs.\n\n# Complexity\n- Time complexity:\nO(nlo
guobao2
NORMAL
2023-10-24T01:55:56.140020+00:00
2023-10-24T03:53:26.969804+00:00
2
false
# Intuition\nThe trick is to sort the words by length. Since it has corresponding groups I create a new array of pairs.\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nrecord Pair(String word, int group) implements Comparable<Pair> {\n\n @Override\n public int compareTo(...
0
0
['Java']
0
longest-unequal-adjacent-groups-subsequence-ii
LIS || Memo + DP Solution
lis-memo-dp-solution-by-shaurya950-5ys5
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
shaurya950
NORMAL
2023-10-22T03:50:09.055508+00:00
2023-10-22T03:50:09.055527+00:00
12
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)$$ --...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
Python | DP | O(n^2)
python-dp-on2-by-aryonbe-sjcj
Code\n\nclass Solution:\n def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:\n def dist(x, y):\n
aryonbe
NORMAL
2023-10-21T09:17:06.136471+00:00
2023-10-21T09:19:44.579217+00:00
6
false
# Code\n```\nclass Solution:\n def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:\n def dist(x, y):\n if len(x) != len(y): return False \n return sum([x[i] != y[i] for i in range(len(x))]) == 1\n n = len(words)\n dp = [1]*n\n ...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
Python from O(n^2) space complexity to O(n) using Dynamic Programming
python-from-on2-space-complexity-to-on-u-0qvc
Intuition\n Describe your first thoughts on how to solve this problem. \nI saw there were subproblems with the amount of choices we had per step. So I thought d
robert961
NORMAL
2023-10-21T00:13:45.644268+00:00
2023-10-21T00:13:45.644285+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nI saw there were subproblems with the amount of choices we had per step. So I thought dynamic programming using a decision tree. I either pick the word or don\'t pick the word. I orginally thought about using the current index and previou...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
C++ || EASY || CLEAN || RECURSIVE DP || MEMOIZATION
c-easy-clean-recursive-dp-memoization-by-cmz2
\n\n# Code\n\nclass Solution {\npublic:\n vector<int> t(int i,map<int,vector<int>> &dp,int n,vector<string> &a,vector<int> &g)\n {\n if(dp.count(i)
Gauravgeekp
NORMAL
2023-10-20T09:37:30.746735+00:00
2023-10-20T09:37:30.746760+00:00
11
false
\n\n# Code\n```\nclass Solution {\npublic:\n vector<int> t(int i,map<int,vector<int>> &dp,int n,vector<string> &a,vector<int> &g)\n {\n if(dp.count(i)>0) return dp[i];\n\n vector<int> r;\n for(int j=i+1;j<n;j++)\n {\n bool b=1;\n int c=0;\n if(a...
0
0
['C++']
0
longest-unequal-adjacent-groups-subsequence-ii
[Python3] Length-wise DP
python3-length-wise-dp-by-cava-dp84
\nclass Solution:\n def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:\n length_groups = [[] for _ in r
cava
NORMAL
2023-10-20T06:27:48.066674+00:00
2023-10-20T06:27:48.066697+00:00
4
false
```\nclass Solution:\n def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:\n length_groups = [[] for _ in range(11)]\n for i, w in enumerate(words): length_groups[len(w)].append((w, groups[i]))\n def calHamming(w1, w2): return sum(1 for c1, c2 in zip...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
Java Simple Solution | TC - O(N^2) | SC - O(N)
java-simple-solution-tc-on2-sc-on-by-omk-270k
\n\n# Complexity\n- Time complexity: O(N^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(N)\n Add your space complexity here, e.g. O(n)
Omkar_Alase
NORMAL
2023-10-20T05:34:08.970528+00:00
2023-10-20T05:34:08.970558+00:00
8
false
\n\n# Complexity\n- Time complexity: O(N^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n private boolean check(String word1,String word2){\n if(word1.length() != word2.length()) ret...
0
0
['Java']
0
longest-unequal-adjacent-groups-subsequence-ii
LIS Variation
lis-variation-by-subhash_pabbineedi-j6ec
Intuition\nhttps://www.youtube.com/watch?v=IFfYfonAFGc&ab_channel=takeUforward\n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n
subhash_pabbineedi
NORMAL
2023-10-18T19:39:58.916436+00:00
2023-10-18T19:39:58.916463+00:00
7
false
# Intuition\nhttps://www.youtube.com/watch?v=IFfYfonAFGc&ab_channel=takeUforward\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)$$ --...
0
0
['C++']
0
longest-unequal-adjacent-groups-subsequence-ii
Top down 2 d DP
top-down-2-d-dp-by-hail-cali-x280
Intuition\n Describe your first thoughts on how to solve this problem. \n\nIt is Take and Not Take questions\n\nit\'s constraints is O((16)^2 * 10) == O(m^2 *
hail-cali
NORMAL
2023-10-18T12:47:03.942304+00:00
2023-10-18T12:47:03.942328+00:00
15
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nIt is `Take and Not Take` questions\n\nit\'s constraints is O((16)^2 * 10) == O(m^2 * n) .\n\nTrying to calculate all `pairs (i, j)` which is ( i< j) and met constraints.\n\nChoose longest subarray and attach one by one. \n\n\n\n\n# A...
0
0
['Python3']
0
longest-unequal-adjacent-groups-subsequence-ii
EASY SOLTUION || ITREATIVE METHOD
easy-soltuion-itreative-method-by-bineet-phe7
Intuition\n Describe your first thoughts on how to solve this problem. \nTHIS PROBLEM IS RELATED TO STANDERED PROBLEM LONGEST INCREASING SUBSEQUENCE WE HAVE TO
bineetkathait1111
NORMAL
2023-10-17T18:58:24.129696+00:00
2023-10-17T18:58:24.129723+00:00
4
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTHIS PROBLEM IS RELATED TO STANDERED PROBLEM LONGEST INCREASING SUBSEQUENCE WE HAVE TO THINK LIKE THAT\n# Approach\n<!-- Describe your approach to solving the problem. -->\nAT CURRENT INDEX WE HAVE TO FIND THE LONGEST INCREASING SUBSEQUEN...
0
0
['Array', 'String', 'C++']
0
longest-unequal-adjacent-groups-subsequence-ii
C++ Solution || Similar to printing LIS
c-solution-similar-to-printing-lis-by-va-ot06
\nclass Solution {\npublic:\n bool check(string s,string t){\n int i,c=0;\n for(i=0;i<s.size();i++){\n if(s[i]!=t[i]){\n
vanapallikavyasri
NORMAL
2023-10-17T16:35:36.075087+00:00
2023-10-17T16:35:36.075119+00:00
3
false
```\nclass Solution {\npublic:\n bool check(string s,string t){\n int i,c=0;\n for(i=0;i<s.size();i++){\n if(s[i]!=t[i]){\n c++;\n }\n }\n return c==1;\n }\n vector<string> getWordsInLongestSubsequence(int n, vector<string>& w, vector<int>& g) {\...
0
0
[]
0
longest-unequal-adjacent-groups-subsequence-ii
C++ - Dynamic Programming
c-dynamic-programming-by-mumrocks-dv6q
Intuition\nKeep track of max sequence formed at index. Max subsequence at index i is found by performing group id check and checking hamming distance between al
MumRocks
NORMAL
2023-10-17T16:05:43.489014+00:00
2023-10-17T16:05:43.489040+00:00
4
false
# Intuition\nKeep track of max sequence formed at index. Max subsequence at index i is found by performing group id check and checking hamming distance between all previous elements. \n\n\n\n# Code\n```\nclass Solution {\n bool IsHammingDistanceOne(const string& f, const string& s){\n int hc=0;\n if (f...
0
0
['C++']
0
find-the-student-that-will-replace-the-chalk
O(n) solution beats 100 % in all languages
on-solution-beats-100-in-all-languages-b-r34m
Intuition\n \nTo start, let\'s first understand what the question is really asking we have a classroom of students each with a specific chalk requirement. The t
Solution_Assist
NORMAL
2024-09-01T18:59:22.734835+00:00
2024-09-02T17:25:34.659108+00:00
31,100
false
## Intuition\n \nTo start, let\'s first understand what the question is really asking we have a classroom of students each with a specific chalk requirement. The teacher goes around the room and starts giving chalk to the students until they run out. Our job is to find out which student will be the one to say, "Hey, we...
70
1
['Simulation', 'Prefix Sum', 'C++', 'Java', 'Go', 'TypeScript', 'Python3', 'Rust', 'JavaScript', 'C#']
13
find-the-student-that-will-replace-the-chalk
Two Tricks
two-tricks-by-votrubac-lmk9
Trick 1: k can be too big, so skip full circles by only considering k % sum(chalk). \nTrick 2: sum(chalk) array can exceed INT_MAX, use long (0l) to accumulate.
votrubac
NORMAL
2021-06-12T16:49:47.809232+00:00
2021-06-12T18:55:34.958511+00:00
7,681
false
Trick 1: `k` can be too big, so skip full circles by only considering `k % sum(chalk)`. \nTrick 2: `sum(chalk)` array can exceed `INT_MAX`, use `long` (`0l`) to accumulate.\n\n**C++**\n```cpp\nint chalkReplacer(vector<int>& chalk, int k) {\n k %= accumulate(begin(chalk), end(chalk), 0l);\n for (int i = 0; i < cha...
70
0
['C']
15
find-the-student-that-will-replace-the-chalk
Python 1-line
python-1-line-by-lee215-jh2p
Solution 1\nTime O(n)\nSpace O(1)\npy\n def chalkReplacer(self, A, k):\n k %= sum(A)\n for i, a in enumerate(A):\n if k < a:\n
lee215
NORMAL
2021-06-12T16:04:34.680743+00:00
2021-06-12T16:04:34.680767+00:00
4,136
false
# **Solution 1**\nTime O(n)\nSpace O(1)\n```py\n def chalkReplacer(self, A, k):\n k %= sum(A)\n for i, a in enumerate(A):\n if k < a:\n return i\n k -= a\n return 0\n```\n# **Solution 2**\nTime O(n)\nSpace O(n)\n```py\n def chalkReplacer(self, A, k):\n ...
46
7
[]
12
find-the-student-that-will-replace-the-chalk
✅Easy and Clean Code (C++ / Java)✅
easy-and-clean-code-c-java-by-sourav_n06-rk66
Here\u2019s a refined version of the explanation:\n\n### Intuition\nThe problem is about determining which student will be the one to use up the last piece of c
sourav_n06
NORMAL
2024-09-02T03:20:35.680568+00:00
2024-09-02T03:20:35.680587+00:00
6,034
false
Here\u2019s a refined version of the explanation:\n\n### Intuition\nThe problem is about determining which student will be the one to use up the last piece of chalk. Since the chalk usage pattern is repetitive, if `k` (the initial amount of chalk) is larger than the total chalk used in one complete cycle, we can simpli...
23
0
['Array', 'Simulation', 'Prefix Sum', 'C++', 'Java']
4
find-the-student-that-will-replace-the-chalk
Prefix Sum + Binary Search||45 ms Beats 98.17%
prefix-sum-binary-search45-ms-beats-9817-03ly
Intuition\n Describe your first thoughts on how to solve this problem. \nUse Prefix sum to count sum[i] of pieces of chalks used up to student[i]\nIf k>sum[n-1]
anwendeng
NORMAL
2024-09-02T01:02:42.627113+00:00
2024-09-02T02:19:36.958963+00:00
8,287
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse Prefix sum to count sum[i] of pieces of chalks used up to student[i]\nIf k>sum[n-1]=total sum of chalk, then use modulo arithmetic & binary search.\n\nBoth C++, Python are made.\n# Approach\n<!-- Describe your approach to solving the ...
23
1
['Binary Search', 'Prefix Sum', 'C++', 'Python3']
14
find-the-student-that-will-replace-the-chalk
[ C++,Python ] Detailed explanation with solution
cpython-detailed-explanation-with-soluti-vev8
\n# Approach\n\nBruteforce approach is that we simulate this process and \nsince k can be large enough and moving one by one until chalk ends can be a bad idea
itz_pankaj
NORMAL
2021-06-12T16:02:07.646871+00:00
2021-06-13T06:22:48.758881+00:00
2,357
false
\n# Approach\n\nBruteforce approach is that we simulate this process and \nsince k can be large enough and moving one by one until chalk ends can be a bad idea and we have to iterate chalk array multiple times\n\n# Improved version\n \nWhat we do is that we take we take sum of all chalk requires by students and our ...
23
3
[]
8
find-the-student-that-will-replace-the-chalk
✔️ PYTHON || EXPLANATION || BINARY SEARCH
python-explanation-binary-search-by-kara-itye
UPVOTE IF HELPFUL\nFind prefix sum first arr [ i ] += arr [ i - 1 ]\n\nThen update k as k = k % arr [ last_element ]\n\nThis will give the last number of chalks
karan_8082
NORMAL
2022-06-07T05:04:58.698694+00:00
2022-06-07T05:04:58.698734+00:00
993
false
**UPVOTE IF HELPFUL**\nFind prefix sum first **arr [ i ] += arr [ i - 1 ]**\n\nThen update k as **k = k % arr [ last_element ]**\n\nThis will give the last number of chalks left for the last cycle to run.\n\nNow using binary search find the element where chalk are consumed , more specifically , the index with smallest ...
17
0
['Binary Tree', 'Prefix Sum']
15
find-the-student-that-will-replace-the-chalk
[Java/Python 3] Two passes O(n) codes.
javapython-3-two-passes-on-codes-by-rock-6ron
Java\n1st pass used to avoid possible int overflow.\n\njava\n public int chalkReplacer(int[] chalk, int k) {\n int sum = 0;\n for (int i = 0; i
rock
NORMAL
2021-06-12T16:11:16.690971+00:00
2024-09-03T13:13:51.884271+00:00
1,241
false
**Java**\n1st pass used to avoid possible int overflow.\n\n```java\n public int chalkReplacer(int[] chalk, int k) {\n int sum = 0;\n for (int i = 0; i < chalk.length; ++i) {\n sum += chalk[i];\n k -= chalk[i];\n if (k < 0) {\n return i;\n }\n ...
14
3
[]
6
find-the-student-that-will-replace-the-chalk
BASIC MATHS ✅✅69_BEATS_100%✅✅🔥Easy Solution🔥With Explanation🔥
basic-maths-69_beats_100easy-solutionwit-a3hw
Intuition\n Describe your first thoughts on how to solve this problem. \nwe need to find out where the chalk runs out \nwe need to find the remainder of the cha
srinivas_bodduru
NORMAL
2024-09-02T02:32:57.533016+00:00
2024-09-02T02:32:57.533049+00:00
4,153
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwe need to find out where the chalk runs out \nwe need to find the remainder of the chalk with the total chalk needed by the studnets to remove unwanted cycles \n# Approach\n<!-- Describe your approach to solving the problem. -->\nwe eill...
13
2
['Array', 'C', 'Simulation', 'Prefix Sum', 'Python', 'C++', 'Python3', 'JavaScript']
9
find-the-student-that-will-replace-the-chalk
✔Java Solution using binary Search with Explanation💯
java-solution-using-binary-search-with-e-wwnz
we will make a prefix sum of the chalk array....and we can optimize the given k as simply jumping to last iteration.\nlike k = 25, and sum = 10, iteration will
harshu175
NORMAL
2021-06-12T16:07:22.688723+00:00
2021-06-22T21:41:41.600187+00:00
1,778
false
we will make a prefix sum of the chalk array....and we can optimize the given k as simply jumping to last iteration.\nlike k = 25, and sum = 10, iteration will be like 25 -> 15 -> 5\nthis can be very long number but if we directly take mod of k % sum..we will be at our last iteration.\nNow, here comes the role of prefi...
12
1
['Binary Tree', 'Java']
5
find-the-student-that-will-replace-the-chalk
Easy and Simple Approach ✅ | Loop-approach ✅ | cpp ✅
easy-and-simple-approach-loop-approach-c-g8mm
Intuition\n Describe your first thoughts on how to solve this problem. \nWe can just get the sum of all the chalk elements and mod them with the k so we get to
parijatb_03
NORMAL
2024-09-02T03:53:21.904189+00:00
2024-09-02T03:53:21.904215+00:00
1,168
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n*We can just get the sum of all the chalk elements and mod them with the k so we get to know how many remains and update value of k as this remainder. Now we simple iterate the chalk array one more time this time we sure there will be no ...
9
0
['C++']
3
find-the-student-that-will-replace-the-chalk
Simple Java || C++ Code ☠️
simple-java-c-code-by-abhinandannaik1717-0sz6
Code\njava []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n int n = chalk.length;\n long sum = 0;\n int i=0;\n
abhinandannaik1717
NORMAL
2024-09-02T16:41:38.174629+00:00
2024-09-02T16:41:38.174654+00:00
112
false
# Code\n```java []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n int n = chalk.length;\n long sum = 0;\n int i=0;\n for(i=0;i<n;i++){\n sum+=chalk[i];\n }\n if(k>=sum){\n k = k%(int)sum;\n }\n for(i=0;i<n;i++){\n ...
8
0
['Array', 'Simulation', 'C++', 'Java']
0
find-the-student-that-will-replace-the-chalk
C++ | Easy to understand | O(n)
c-easy-to-understand-on-by-di_b-y50x
\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n long sum = 0;\n for(int i =0; i < chalk.size(); ++i)\n
di_b
NORMAL
2021-06-12T16:02:29.451899+00:00
2021-06-12T17:19:09.673286+00:00
448
false
```\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n long sum = 0;\n for(int i =0; i < chalk.size(); ++i)\n sum += chalk[i];\n k = k%sum;\n for(int i =0; i < chalk.size(); ++i)\n {\n if(k < chalk[i])\n return i;\n ...
8
6
[]
1
find-the-student-that-will-replace-the-chalk
Easy Solution
easy-solution-by-viratkohli-xyyl
Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\n# Code
viratkohli_
NORMAL
2024-09-02T02:50:38.489671+00:00
2024-09-02T02:50:38.489689+00:00
481
false
# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n long long sum = 0;\n for(int ...
7
0
['C++']
1
find-the-student-that-will-replace-the-chalk
✅ One Line Solution
one-line-solution-by-mikposp-t43q
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1\nTime complexity: O(n). Space complexi
MikPosp
NORMAL
2024-09-02T07:50:00.872915+00:00
2024-09-04T06:34:48.047205+00:00
461
false
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n def chalkReplacer(self, a: List[int], k: int) -> int:\n return bisect_left(p:=[*accumulate(a)],k%p[-1])\n```...
6
1
['Array', 'Binary Search', 'Simulation', 'Prefix Sum', 'Python', 'Python3']
1
find-the-student-that-will-replace-the-chalk
C++ ✅ ✅ easy to understand o(n) prefixSUM || BS.
c-easy-to-understand-on-prefixsum-bs-by-dtlim
\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& c, int k) {\n long n = c.size(), sum, left;\n vector<long> pref(n); // creating n
dynamo_518
NORMAL
2024-09-02T05:07:08.052984+00:00
2024-09-02T06:54:32.305698+00:00
767
false
```\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& c, int k) {\n long n = c.size(), sum, left;\n vector<long> pref(n); // creating new prefix sum vector due to overflow else not requried \n pref[0] = c[0];\n for(int i = 1;i<n;i++) pref[i] = pref[i-1] + c[i];\n sum = p...
6
0
['Binary Search', 'C', 'Prefix Sum']
3
find-the-student-that-will-replace-the-chalk
✅Find the Student that will Replace the Chalk ✅ || Easy thought process in CPP🔥🔥
find-the-student-that-will-replace-the-c-c68j
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem asks us to find which student will be the first to run out of chalk given a
Ashis2024
NORMAL
2024-09-02T04:38:49.623190+00:00
2024-09-02T04:38:49.623216+00:00
488
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem asks us to find which student will be the first to run out of chalk given a large number of units (k). Each student uses a certain amount of chalk, and this process repeats cyclically. If k is large, it\'s inefficient to simul...
6
0
['C++']
1
find-the-student-that-will-replace-the-chalk
C++ || SERIOUSLY? IT REQUIRED BINARY SEARCH OR PREFIX SUM?
c-seriously-it-required-binary-search-or-7g08
```\nclass Solution {\npublic:\n int chalkReplacer(vector& chalk, int k) {\n long long sum =0;\n for(int ele : chalk){\n sum = sum +
Easy_coder
NORMAL
2022-03-12T15:51:16.300766+00:00
2022-03-12T15:51:16.300793+00:00
697
false
```\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n long long sum =0;\n for(int ele : chalk){\n sum = sum + (long long)ele;\n }\n k = ((long long)k) % sum;\n int i =0;\n while( i < chalk.size()){\n // cout<<k<<" ";\n ...
6
0
['C']
2
find-the-student-that-will-replace-the-chalk
Python || Prefix Sum and Binary Search || O(n) time O(n) space
python-prefix-sum-and-binary-search-on-t-qmh5
\nclass Solution:\n def chalkReplacer(self, chalk: List[int], k: int) -> int:\n prefix_sum = [0 for i in range(len(chalk))]\n prefix_sum[0] = c
s_m_d_29
NORMAL
2021-12-05T06:41:44.879738+00:00
2021-12-05T06:41:44.879774+00:00
834
false
```\nclass Solution:\n def chalkReplacer(self, chalk: List[int], k: int) -> int:\n prefix_sum = [0 for i in range(len(chalk))]\n prefix_sum[0] = chalk[0]\n for i in range(1,len(chalk)):\n prefix_sum[i] = prefix_sum[i-1] + chalk[i]\n remainder = k % prefix_sum[-1]\n \n ...
6
0
['Binary Search', 'Prefix Sum', 'Python', 'Python3']
2
find-the-student-that-will-replace-the-chalk
Simple Java
simple-java-by-scala62-mve8
\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n long sum = 0;\n for (int c : chalk) {\n sum += c; \n }\
scala62
NORMAL
2021-06-12T16:01:29.804682+00:00
2021-06-12T16:01:29.804719+00:00
657
false
```\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n long sum = 0;\n for (int c : chalk) {\n sum += c; \n }\n k = (int)((long)k % sum);\n int count = 0;\n while (k > 0) {\n k -= chalk[count++];\n }\n return k == 0 ? cou...
6
1
[]
0
find-the-student-that-will-replace-the-chalk
Beats 90% Runtime 2ms || Best Java Solution || Intuition & Approach Explained
beats-90-runtime-2ms-best-java-solution-h8i2w
Intuition\nThe problem asks to find out which student will run out of chalk first when distributing k units of chalk according to the amounts specified in the c
raghavagarwal28
NORMAL
2024-09-02T16:30:14.753126+00:00
2024-09-09T07:30:09.692896+00:00
128
false
# Intuition\nThe problem asks to find out which student will run out of chalk first when distributing k units of chalk according to the amounts specified in the chalk array. The naive approach might involve repeatedly iterating through the chalk array and subtracting the values from k until k is less than the amount re...
5
0
['Array', 'Simulation', 'Java']
4
find-the-student-that-will-replace-the-chalk
Simple and Easy CPP Code!💯✅☮️
simple-and-easy-cpp-code-by-siddharth_si-ovw7
\n\n# Code\ncpp []\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n int c = 0;\n long long sum=0;\n for(int
siddharth_sid_k
NORMAL
2024-09-02T14:45:08.331538+00:00
2024-09-02T14:45:08.331578+00:00
80
false
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n int c = 0;\n long long sum=0;\n for(int i=0;i<chalk.size();i++)\n {\n sum+=chalk[i];\n }\n k=k%sum;\n for (int i = 0; i < chalk.size() ;i++) {\n ...
5
0
['C++']
0
find-the-student-that-will-replace-the-chalk
Calculate Remaining Chalk Using Modulus Operation | Java | C++ | [Video Solution]
calculate-remaining-chalk-using-modulus-hum6d
Intuition, approach, and complexity discussed in video solution in detail\nhttps://youtu.be/dX8IWRDMUb0\n# Code\njava []\nclass Solution {\n public int chalk
Lazy_Potato_
NORMAL
2024-09-02T05:45:34.550875+00:00
2024-09-02T05:45:34.550903+00:00
918
false
# Intuition, approach, and complexity discussed in video solution in detail\nhttps://youtu.be/dX8IWRDMUb0\n# Code\n``` java []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n long totalChkNeed = 0l;\n for(var chkNeed : chalk){\n totalChkNeed += chkNeed;\n }\n ...
5
0
['Array', 'Simulation', 'C++', 'Java']
2
find-the-student-that-will-replace-the-chalk
Only Solution You'll Need || Simulation || Explained line-by-line (Python)
only-solution-youll-need-simulation-expl-jxj9
Intuition\n Describe your first thoughts on how to solve this problem. \nYou have a list of integers, chalk, where chalk[i] represents the amount of chalk the i
anand_shukla1312
NORMAL
2024-09-02T04:40:02.422161+00:00
2024-09-02T04:40:51.268517+00:00
66
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nYou have a list of integers, `chalk`, where `chalk[i]` represents the amount of chalk the `i-th` student uses before passing it to the next student. The process starts with`k` pieces of `chalk`. The students use chalk cyclically, and once...
5
0
['Array', 'Math', 'Simulation', 'Python3']
0
find-the-student-that-will-replace-the-chalk
Python Easy Solution
python-easy-solution-by-lokeshsk1-ct2q
\ndef chalkReplacer(self, chalk: List[int], k: int) -> int:\n\n\tk %= sum(chalk)\n\n\tfor i in range(len(chalk)):\n\t\tif chalk[i]>k:\n\t\t\treturn i\n\t\tk -=
lokeshsk1
NORMAL
2021-06-12T16:25:23.115817+00:00
2021-06-12T16:25:36.490547+00:00
496
false
```\ndef chalkReplacer(self, chalk: List[int], k: int) -> int:\n\n\tk %= sum(chalk)\n\n\tfor i in range(len(chalk)):\n\t\tif chalk[i]>k:\n\t\t\treturn i\n\t\tk -= chalk[i]\n```\n
5
0
['Python', 'Python3']
4
find-the-student-that-will-replace-the-chalk
✅💯🔥Simple Code📌🚀| 🔥✔️Easy to understand🎯 | 🎓🧠Beginner friendly🔥| O(n) Time Complexity💀💯
simple-code-easy-to-understand-beginner-cefb0
Tuntun Mosi ko Pranam\nSolution tuntun mosi ki photo ke baad hai. Scroll Down\n\n# Code\njava []\nclass Solution {\n public int chalkReplacer(int[] chalks, i
atishayj4in
NORMAL
2024-09-11T17:40:01.440746+00:00
2024-09-11T17:40:01.440785+00:00
67
false
# Tuntun Mosi ko Pranam\nSolution tuntun mosi ki photo ke baad hai. Scroll Down\n![fd9d3417-20fb-4e19-98fa-3dd39eeedf43_1723794694.932518.png](https://assets.leetcode.com/users/images/a492c0ef-bde0-4447-81e6-2ded326cd877_1724187540.6168394.png)\n# Code\n```java []\nclass Solution {\n public int chalkReplacer(int[] c...
4
0
['Array', 'Binary Search', 'C', 'Simulation', 'Prefix Sum', 'Python', 'C++', 'Java', 'JavaScript']
1
find-the-student-that-will-replace-the-chalk
Simple Linear time Solution | 99% Beats | Java
simple-linear-time-solution-99-beats-jav-ytcw
\n# Code\njava []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n int sum = 0;\n for(int i = 0; i < chalk.length; i++) {\n
eshwaraprasad
NORMAL
2024-09-02T07:10:04.871883+00:00
2024-09-02T07:10:04.871902+00:00
168
false
\n# Code\n```java []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n int sum = 0;\n for(int i = 0; i < chalk.length; i++) {\n sum += chalk[i];\n if (sum > k) return i;\n }\n\n k %= sum;\n\n for(int i = 0; i < chalk.length; i++) {\n ...
4
0
['Java']
0
find-the-student-that-will-replace-the-chalk
Easy C++ solution using mod(for beginners) || Beats 80%
easy-c-solution-using-modfor-beginners-b-p5od
\n\n# Approach\nModulo Optimization:\nYou compute the sum of all chalk usages, then reduce k by taking k % sum. This step ensures that t is minimized and within
Vamp101
NORMAL
2024-09-02T05:40:54.986512+00:00
2024-09-02T05:40:54.986561+00:00
199
false
\n\n# Approach\nModulo Optimization:\nYou compute the sum of all chalk usages, then reduce k by taking k % sum. This step ensures that t is minimized and within the range of one complete cycle through the chalk array, eliminating unnecessary full cycles.\n\nLoop Through Students:\nThe loop iterates through each student...
4
0
['Array', 'Simulation', 'C++']
2
find-the-student-that-will-replace-the-chalk
Binary Search approach optimal | java
binary-search-approach-optimal-java-by-p-6hnl
\n# Approach\n Describe your approach to solving the problem. \nOptimal approach using binary search\n# Complexity\n- Time complexity:O(n+logn)=O(n)\n Add your
pala_04
NORMAL
2024-09-02T04:09:52.334000+00:00
2024-09-02T04:09:52.334035+00:00
598
false
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nOptimal approach using binary search\n# Complexity\n- Time complexity:O(n+logn)=O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\ncl...
4
0
['Array', 'Binary Search', 'Simulation', 'Prefix Sum', 'Java']
1
find-the-student-that-will-replace-the-chalk
🌟| Efficient Solution | 76ms Beats 95.27% | C++ Java Py3 | O(n) |
efficient-solution-76ms-beats-9527-c-jav-ucdz
\n#\n---\n\n## Intuition\nWe need to keep track of the total amount of chalk each student uses until the remaining chalk is insufficient for the next student. T
user4612MW
NORMAL
2024-09-02T03:30:46.776366+00:00
2024-09-02T03:33:10.135413+00:00
13
false
\n#\n---\n\n## Intuition\nWe need to keep track of the total amount of chalk each student uses until the remaining chalk is insufficient for the next student. The efficient way to approach this is by first summing up the total chalk usage in one full round. Then, instead of repeatedly subtracting the chalk for every st...
4
0
['C++', 'Java', 'Python3']
0
find-the-student-that-will-replace-the-chalk
simple and easy explained Python solution 😍❤️‍🔥
simple-and-easy-explained-python-solutio-xw9r
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Follow on Github: www.github.com/shishirRsiam\n###### Let\'s Connect on LinkedIn: www.linkedin.
shishirRsiam
NORMAL
2024-09-02T03:12:41.507947+00:00
2024-09-02T03:12:41.507986+00:00
572
false
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Follow on Github: www.github.com/shishirRsiam\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook: www.fb.com/shishirrsiam\n\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, ...
4
0
['Array', 'Binary Search', 'Simulation', 'Prefix Sum', 'Python', 'Python3']
6
find-the-student-that-will-replace-the-chalk
Simple easy to understand solution.
simple-easy-to-understand-solution-by-co-rw7w
Intuition\nJust apply basic maths. Fully explained within the code.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solu
codeHunter01
NORMAL
2023-04-06T07:28:46.757664+00:00
2023-04-06T07:28:46.757690+00:00
633
false
# Intuition\nJust apply basic maths. Fully explained within the code.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n int n= chalk.length;\n\n // First calculate the total sum of the array\n ...
4
0
['Array', 'Binary Search', 'Java']
2
find-the-student-that-will-replace-the-chalk
Java Easy Solution ( O(n) time | O(1) space )
java-easy-solution-on-time-o1-space-by-t-xh1c
Intuition\nuse prefix sum to find that student in single round\n\n# Approach\nprefix sum to calculate number of chalks require for students \n\n# Complexity\n-
TSumit
NORMAL
2022-12-11T11:03:21.238791+00:00
2022-12-11T11:03:21.238824+00:00
587
false
# Intuition\nuse prefix sum to find that student in single round\n\n# Approach\nprefix sum to calculate number of chalks require for students \n\n# Complexity\n- Time complexity:\n O(n) time {O(n)+O(n)} is used for (n=length of chalk array) \n O(n) for prefix sum ans O(n) for serching student\n- Space complexity...
4
0
['Java']
1
find-the-student-that-will-replace-the-chalk
Two approaches || O(n) - Javasript >>
two-approaches-on-javasript-by-ravitejay-gy6o
(1)\n\n\tlet sum = chalk.reduce((s,ele) => s + ele, 0);\n let iter = Math.floor(k/sum);\n let i=0;\n while(i < iter){\n k -= sum;\n i++;\
ravitejay
NORMAL
2022-10-06T12:21:58.416110+00:00
2023-01-19T04:16:15.875812+00:00
251
false
# (1)\n```\n\tlet sum = chalk.reduce((s,ele) => s + ele, 0);\n let iter = Math.floor(k/sum);\n let i=0;\n while(i < iter){\n k -= sum;\n i++;\n }\n for(let i=0; i<chalk.length; i++){\n if(k >= chalk[i]){\n k -= chalk[i]\n } else {\n return i;\n }\n...
4
0
['Binary Tree', 'JavaScript']
1
find-the-student-that-will-replace-the-chalk
javascript binary search solution
javascript-binary-search-solution-by-chr-y8t5
Iteration solution\n\nvar chalkReplacer = function(chalk, k) {\n let arr = new Array(chalk.length)\n let sum = 0\n for(let i =0; i< chalk.length; i++){
chriskk
NORMAL
2021-09-16T22:58:02.908820+00:00
2021-09-16T22:59:00.381789+00:00
200
false
**Iteration solution**\n```\nvar chalkReplacer = function(chalk, k) {\n let arr = new Array(chalk.length)\n let sum = 0\n for(let i =0; i< chalk.length; i++){\n sum += chalk[i]\n arr[i]= sum\n }\n k = k%sum\n if(k==0 || k < chalk[0])\n return 0\n \n for(let i =0; i< chalk.le...
4
0
['Binary Tree', 'JavaScript']
3
find-the-student-that-will-replace-the-chalk
Python 3 | O(N) | Explanation
python-3-on-explanation-by-idontknoooo-3r57
Mod the total sum of chalk, so that k can be exhaust in one iteration\n- Then, iterate over chalk to find student i\n\nclass Solution:\n def chalkReplacer(se
idontknoooo
NORMAL
2021-09-01T17:14:22.981300+00:00
2021-09-01T17:14:22.981365+00:00
240
false
- Mod the total sum of `chalk`, so that `k` can be exhaust in one iteration\n- Then, iterate over `chalk` to find student i\n```\nclass Solution:\n def chalkReplacer(self, chalk: List[int], k: int) -> int:\n k %= sum(chalk)\n for i, num in enumerate(chalk):\n if k >= num: k -= num\n ...
4
0
['Array', 'Python', 'Python3']
1
find-the-student-that-will-replace-the-chalk
java easy and 100% time & 100% space
java-easy-and-100-time-100-space-by-jssa-5apl
\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n \n long sum = 0;\n for(int i = 0;i<chalk.length;i++){\n s
jssam002
NORMAL
2021-06-13T08:05:43.749376+00:00
2021-06-13T08:05:43.749419+00:00
243
false
```\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n \n long sum = 0;\n for(int i = 0;i<chalk.length;i++){\n sum+=chalk[i];\n k = k-chalk[i];\n if(k<0){\n return i;\n }\n }\n System.out.println(sum);\n ...
4
0
[]
0
find-the-student-that-will-replace-the-chalk
c++
c-by-rajat_gupta-qq7y
\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n long int sum=accumulate(chalk.begin() , chalk.end() , 0l);\n\t\t//we su
rajat_gupta_
NORMAL
2021-06-12T20:43:10.102974+00:00
2021-06-12T20:48:13.392023+00:00
209
false
```\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n long int sum=accumulate(chalk.begin() , chalk.end() , 0l);\n\t\t//we subtract the multiple of sum of chalks from the total chalks.\n k%=sum;\n\t\t//Now we distribute the remaining chalks from student 0 untill chalks are s...
4
2
['C', 'C++']
2
find-the-student-that-will-replace-the-chalk
Python | simple O(N)
python-simple-on-by-harshhx-rrk8
\nclass Solution:\n def chalkReplacer(self, chalk: List[int], k: int) -> int:\n x = sum(chalk)\n if x<k:\n k = k%x\n if x ==
harshhx
NORMAL
2021-06-12T16:07:57.992669+00:00
2021-06-13T02:15:16.784064+00:00
493
false
```\nclass Solution:\n def chalkReplacer(self, chalk: List[int], k: int) -> int:\n x = sum(chalk)\n if x<k:\n k = k%x\n if x == k:\n return 0\n i = 0\n n = len(chalk)\n while True:\n if chalk[i]<=k:\n k -= chalk[i]\n ...
4
0
['Python', 'Python3']
2
find-the-student-that-will-replace-the-chalk
2 Approaches!✅One Beats 99.19% with 1ms Solution💯 and other Brute Force with 2938ms
2-approachesone-beats-9919-with-1ms-solu-s8s1
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nInitially the approach is very simple and naive , i.e to iterate the loop
ArcuLus
NORMAL
2024-09-03T15:10:43.641542+00:00
2024-09-03T15:10:43.641577+00:00
11
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nInitially the approach is very simple and naive , i.e to iterate the loop till k becomes 0 , good for small iteration , very bad for big ones , that\'s why we got this much complexity which Mathematically it\'s O(n) only \n\...
3
0
['Java']
2
find-the-student-that-will-replace-the-chalk
Simple Solution with Approach | 🚀
simple-solution-with-approach-by-hemants-fqqo
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nImagine how many comple
hemantsingh_here
NORMAL
2024-09-02T18:25:33.884384+00:00
2024-09-02T18:25:33.884417+00:00
10
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nImagine how many complete rounds of chalk array you can take, suppose k = 25 and sum(chalk) = 10, then we can take 2 complete rounds and we have 5 remaining chalks. Th...
3
0
['Array', 'C++']
0
find-the-student-that-will-replace-the-chalk
💢☠💫Easiest👾Faster✅💯 Lesser🧠 🎯 C++✅Python3🐍✅Java✅C✅Python🐍✅C#✅💥🔥💫Explained☠💥🔥 Beats 100
easiestfaster-lesser-cpython3javacpython-6b02
Intuition\n\n Describe your first thoughts on how to solve this problem. \n- JavaScript Code --> https://leetcode.com/problems/find-the-student-that-will-replac
Edwards310
NORMAL
2024-09-02T14:35:36.254668+00:00
2024-09-02T17:57:18.009286+00:00
64
false
# Intuition\n![0ehh83fsnh811.jpg](https://assets.leetcode.com/users/images/46a18df5-e015-49e3-868a-c0d3fa57d817_1725287505.5460289.jpeg)\n<!-- Describe your first thoughts on how to solve this problem. -->\n- ***JavaScript Code -->*** https://leetcode.com/problems/find-the-student-that-will-replace-the-chalk/submission...
3
0
['Array', 'C', 'Simulation', 'Python', 'C++', 'Java', 'Python3', 'JavaScript', 'C#']
0
find-the-student-that-will-replace-the-chalk
Easy Simulation Trick | Layman Language Explanation
easy-simulation-trick-layman-language-ex-x9e7
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem involves finding out which student will not have enough chalk to continue w
AkashGupta7
NORMAL
2024-09-02T08:09:58.793671+00:00
2024-09-02T08:09:58.793695+00:00
55
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem involves finding out which student will not have enough chalk to continue when a large number of chalks are distributed. Initially, it seemed like a direct simulation could work, but for large values of `k`, simulating each st...
3
0
['Array', 'Simulation', 'C++']
0
find-the-student-that-will-replace-the-chalk
Best solution in java || Simple approach ||
best-solution-in-java-simple-approach-by-hw9l
Intuition\nWhen solving this problem, the main observation is that repeatedly looping through the array for every iteration of k is unnecessary. Since the sum o
Surbhi_Pandey
NORMAL
2024-09-02T07:11:46.467231+00:00
2024-09-02T07:11:46.467260+00:00
192
false
# Intuition\nWhen solving this problem, the main observation is that repeatedly looping through the array for every iteration of k is unnecessary. Since the sum of the chalk usage is constant in every full round, we can reduce k by taking its modulo with the total chalk consumption for one full round. This way, we only...
3
0
['Java']
2
find-the-student-that-will-replace-the-chalk
JAVA | 99% Beats | Linear Approach with Constant Space
java-99-beats-linear-approach-with-const-o0dq
\n# Complexity\n- Time complexity: O(n) \n\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \
SudhikshaGhanathe
NORMAL
2024-09-02T06:30:34.491521+00:00
2024-09-02T06:30:34.491552+00:00
146
false
\n# Complexity\n- Time complexity: O(n) \n\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n\n int sum = 0;\n\n for (int i ...
3
0
['Array', 'Java']
0
find-the-student-that-will-replace-the-chalk
Easy O(N) solution beats 100% --->
easy-on-solution-beats-100-by-its_shiv43-h4d8
Approach\n1. Calculate the total sum: First, calculate the total sum of chalk required by all students.\n2. Reduce k modulo sum: Use the modulo operation to red
its_shiv43
NORMAL
2024-09-02T06:10:18.551522+00:00
2024-09-02T06:10:18.551561+00:00
249
false
# Approach\n1. Calculate the total sum: First, calculate the total sum of chalk required by all students.\n2. Reduce k modulo sum: Use the modulo operation to reduce k by the total sum, as once the chalk runs out and starts over, it effectively loops back.\n3. Find the student: Iterate through the list of students and ...
3
0
['Array', 'Binary Search', 'Simulation', 'Prefix Sum', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
0
find-the-student-that-will-replace-the-chalk
💡 C++ | O(n) | Using Math | Fully Explained ✏️
c-on-using-math-fully-explained-by-tusha-e4f9
Intuition\n- Cyclic Nature: The use of the modulus operator simplifies the problem by reducing it to a smaller, equivalent problem size, reflecting the cyclic n
Tusharr2004
NORMAL
2024-09-02T05:25:47.900237+00:00
2024-09-02T05:25:47.900270+00:00
3
false
# Intuition\n- **Cyclic Nature:** The use of the modulus operator simplifies the problem by reducing it to a smaller, equivalent problem size, reflecting the cyclic nature of the students needing chalk.\n- **Efficiency:** Instead of simulating every unit of chalk usage, the code efficiently finds the result by working ...
3
0
['Math', 'C++']
0
find-the-student-that-will-replace-the-chalk
Beats 97% || Easy to Understand C++ code
beats-97-easy-to-understand-c-code-by-ji-ebgn
Intuition\nThe intuition behind this approach is to first reduce the problem by handling the cyclic nature of the chalk distribution, making it more manageable.
jitenagarwal20
NORMAL
2024-09-02T05:19:13.456321+00:00
2024-09-02T05:19:13.456359+00:00
36
false
# Intuition\nThe intuition behind this approach is to first reduce the problem by handling the cyclic nature of the chalk distribution, making it more manageable. Then, by iterating through the students, we can quickly identify the first student who will run out of chalk after the remaining k chalks are distributed.\n\...
3
0
['C++']
0
find-the-student-that-will-replace-the-chalk
Python | Greedy
python-greedy-by-khosiyat-l62w
see the Successfully Accepted Submission\n\n# Code\npython3 []\nclass Solution:\n def chalkReplacer(self, chalk: List[int], k: int) -> int:\n # Step 1
Khosiyat
NORMAL
2024-09-02T05:17:20.556207+00:00
2024-09-02T05:17:20.556240+00:00
370
false
[see the Successfully Accepted Submission](https://leetcode.com/problems/find-the-student-that-will-replace-the-chalk/submissions/1376082291/?envType=daily-question&envId=2024-09-02)\n\n# Code\n```python3 []\nclass Solution:\n def chalkReplacer(self, chalk: List[int], k: int) -> int:\n # Step 1: Calculate the...
3
0
['Python3']
0
find-the-student-that-will-replace-the-chalk
✅ 🔥 Java | Greedy | 100% faster with O(N) and O(1) ✅ 🔥
java-greedy-100-faster-with-on-and-o1-by-hare
Intuition\n Describe your first thoughts on how to solve this problem. \nSubtracting k from each student\'s chalk count step by step is a redundant task, so I d
Surendaar
NORMAL
2024-09-02T04:55:18.078774+00:00
2024-09-02T16:02:02.930677+00:00
181
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSubtracting k from each student\'s chalk count step by step is a redundant task, so I decided to sum the counts and use modulo k to directly reach the final lap of the cycle.\n# Approach\n<!-- Describe your approach to solving the problem...
3
0
['Greedy', 'Java']
0
find-the-student-that-will-replace-the-chalk
C# Solution for Find the Student that Will Replace the Chalk Problem
c-solution-for-find-the-student-that-wil-zf21
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem revolves around distributing chalk to students in a cyclic manner until the
Aman_Raj_Sinha
NORMAL
2024-09-02T03:53:09.913968+00:00
2024-09-02T03:53:09.913993+00:00
84
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem revolves around distributing chalk to students in a cyclic manner until the chalk runs out. Given the constraints, a direct simulation would be inefficient, so we can optimize the process by leveraging a prefix sum array combi...
3
0
['C#']
0
find-the-student-that-will-replace-the-chalk
simple and easy explained Javascript solution 😍❤️‍🔥
simple-and-easy-explained-javascript-sol-kyu0
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Follow on Github: www.github.com/shishirRsiam\n###### Let\'s Connect on LinkedIn: www.linkedin.
shishirRsiam
NORMAL
2024-09-02T03:16:23.099513+00:00
2024-09-02T03:16:23.099562+00:00
211
false
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Follow on Github: www.github.com/shishirRsiam\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook: www.fb.com/shishirrsiam\n\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, ...
3
0
['Array', 'Binary Search', 'Simulation', 'Prefix Sum', 'JavaScript']
6
find-the-student-that-will-replace-the-chalk
simple and easy explained C++ solution 😍❤️‍🔥
simple-and-easy-explained-c-solution-by-r0kqy
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Follow on Github: www.github.com/shishirRsiam\n###### Let\'s Connect on LinkedIn: www.linkedin.
shishirRsiam
NORMAL
2024-09-02T03:09:18.940955+00:00
2024-09-02T03:09:18.940978+00:00
393
false
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Follow on Github: www.github.com/shishirRsiam\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook: www.fb.com/shishirrsiam\n\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, ...
3
0
['Array', 'Binary Search', 'Simulation', 'Prefix Sum', 'C++']
7
find-the-student-that-will-replace-the-chalk
✅Simple Prefix Sum (C++/Java/Python) Solution With Detailed Explanation✅
simple-prefix-sum-cjavapython-solution-w-lwfq
Detailed Explanation\n\n1. Initialization:\n cpp\n int n = chalk.size();\n long long int sum = 0;\n\n - n stores the number of elements in the chalk
suyogshete04
NORMAL
2024-07-06T06:42:25.716129+00:00
2024-07-06T06:42:25.716171+00:00
480
false
# Detailed Explanation\n\n1. **Initialization**:\n ```cpp\n int n = chalk.size();\n long long int sum = 0;\n ```\n - `n` stores the number of elements in the `chalk` vector.\n - `sum` is initialized to store the total amount of chalk needed for one complete round.\n\n2. **Calculating the Total Chalk U...
3
0
['Array', 'Prefix Sum', 'C++', 'Java', 'Python3']
1
find-the-student-that-will-replace-the-chalk
2 C++ solutions || Binary search || Prefix-Sum || Beats 90% !!
2-c-solutions-binary-search-prefix-sum-b-8edr
Code\n\n// Solution 1\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n int n = chalk.size();\n vector<long long> p
prathams29
NORMAL
2023-07-12T07:39:46.149618+00:00
2023-07-12T07:39:46.149646+00:00
352
false
# Code\n```\n// Solution 1\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n int n = chalk.size();\n vector<long long> pref(n);\n pref[0] = chalk[0];\n for(int i = 1; i < n; i++)\n pref[i] = chalk[i] + pref[i-1];\n k %= pref[n-1];\n int...
3
0
['Binary Search', 'Prefix Sum', 'C++']
1
find-the-student-that-will-replace-the-chalk
Python: Explained Easy O(n) Solution
python-explained-easy-on-solution-by-mea-xwbm
One way to think this is, Iterate through each chalk and keep decrementing K, till K becomes negative.\nTime = O(n * ( k / sum(chalk)) But This will give TLE. \
meaditya70
NORMAL
2021-06-12T16:16:23.476223+00:00
2021-06-12T16:34:00.786995+00:00
105
false
One way to think this is, Iterate through each chalk and keep decrementing K, till K becomes negative.\nTime = O(n * ( k / sum(chalk)) But This will give TLE. \n```\n\tdef chalkReplacer(self, chalk: List[int], k: int) -> int:\n n = len(chalk)\n while True:\n for i in range(n):\n ...
3
0
['Python']
0
find-the-student-that-will-replace-the-chalk
Java Short Code with explanation | Logic
java-short-code-with-explanation-logic-b-sen8
\nSince we know every chalk is consumed fully we can cancel the iterations that the teacher makes from begining to end by assiging them to students. Lets see ho
sandip_jana
NORMAL
2021-06-12T16:02:04.751373+00:00
2021-06-13T05:25:45.075293+00:00
282
false
\nSince we know every chalk is consumed fully we can cancel the iterations that the teacher makes from begining to end by assiging them to students. Lets see how.\n\nSo we know when the teacher starts distributing chalks and does that till the end of array she has distributed\n\n= chalk[0] + chalk[1] + chalk[2] + .... ...
3
0
['Greedy', 'Java']
2
find-the-student-that-will-replace-the-chalk
Beats 100%, beginner way
beats-100-beginner-way-by-coderashu1-tlz8
IntuitionThe problem revolves around efficiently determining which student will run out of chalk during a repetitive distribution process. If we naively simulat
coderashu1
NORMAL
2024-12-26T08:21:01.158593+00:00
2024-12-26T08:21:01.158593+00:00
21
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem revolves around efficiently determining which student will run out of chalk during a repetitive distribution process. If we naively simulate the entire process, it may take too long for large inputs. Instead, we can optimize the...
2
0
['C++']
0
find-the-student-that-will-replace-the-chalk
O(N) - Beats 93.23% in Cpp - Basic Math
on-beats-9323-in-cpp-basic-math-by-jamiy-ng3s
Intuition\nThe problem asks us to determine which student will be unable to continue drawing with chalk once the chalk runs out. Since each student uses a certa
Jamiyat
NORMAL
2024-09-02T18:23:39.523157+00:00
2024-09-02T18:24:33.133533+00:00
0
false
# Intuition\nThe problem asks us to determine which student will be unable to continue drawing with chalk once the chalk runs out. Since each student uses a certain amount of chalk in a cyclic manner, a key observation is that the total amount of chalk used by all students in one complete cycle can be used to reduce th...
2
0
['C++']
0
find-the-student-that-will-replace-the-chalk
Easy Solution in O(n) time.Beats 99%
easy-solution-in-on-timebeats-99-by-prat-vjy5
Approach\nwe Know then after all student are done we revert back to the first student so we need to take the modulo of total sum of array.\nNow we need to trave
pratyush4competative
NORMAL
2024-09-02T18:05:04.012713+00:00
2024-09-02T18:05:04.012740+00:00
9
false
# Approach\nwe Know then after all student are done we revert back to the first student so we need to take the modulo of total sum of array.\nNow we need to traverse the array only once and check where K becomes less than chalk[i].\n\n# Complexity\n- Time complexity:O(n)\n\n- Space complexity:O(n)\n# Code\n```cpp []\nc...
2
0
['Array', 'Simulation', 'Prefix Sum', 'C++']
0
find-the-student-that-will-replace-the-chalk
Solution By Dare2Solve | Detailed Explanation | Clean Code
solution-by-dare2solve-detailed-explanat-ybx3
Explanation []\nauthorslog.com/blog/BPkbFkKeLD\n\n# Code\n\ncpp []\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n long
Dare2Solve
NORMAL
2024-09-02T17:47:34.147474+00:00
2024-09-02T17:47:34.147511+00:00
15
false
```Explanation []\nauthorslog.com/blog/BPkbFkKeLD\n```\n# Code\n\n```cpp []\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n long long total = 0;\n for (int c : chalk) {\n total += c;\n }\n\n k %= total;\n\n for (int i = 0; i < chalk.size(); ...
2
0
['Binary Search', 'Simulation', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
0
find-the-student-that-will-replace-the-chalk
Simple to follow (1 ms Beats 99.36%)
simple-to-follow-1-ms-beats-9936-by-neha-jov8
Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\n# Code
NehaSinghal032415
NORMAL
2024-09-02T17:43:11.241999+00:00
2024-09-02T17:43:11.242029+00:00
6
false
# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n int sum=0;\n for(int i=0;i<chalk.leng...
2
0
['Array', 'Java']
0
find-the-student-that-will-replace-the-chalk
Efficient Solution to Find the Student Who Will Replace the Chalk with O(n) Complexity
efficient-solution-to-find-the-student-w-r8t2
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
shoaibkhalid65
NORMAL
2024-09-02T17:21:23.416843+00:00
2024-09-02T17:21:23.416879+00:00
11
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:\nThis program runs in 1ms and beats 99.36%\n\n- Space complexity:\nThis program\'s memory is 60MB and beats 41%\n\n# Code\n```java [...
2
0
['Java']
1
find-the-student-that-will-replace-the-chalk
🔥99.36% beats🔥with proof 💫 easy java solution
9936-beatswith-proof-easy-java-solution-iu9oy
\n# Approach\n Describe your approach to solving the problem. \n- Sum Calculation: First, calculate the total chalk required for one complete round by summing u
Jayaanthsr
NORMAL
2024-09-02T15:10:22.678691+00:00
2024-09-02T15:10:22.678718+00:00
4
false
\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- **Sum Calculation:** First, calculate the total chalk required for one complete round by summing up the chalk each student uses.\n- **Modulo Operation:** Use modulo operation to find the remaining chalk after all possible full rounds. This is equi...
2
0
['Java']
0
find-the-student-that-will-replace-the-chalk
Easy to Understand || C++ Code
easy-to-understand-c-code-by-brightworld-gvon
Code\ncpp []\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n int n = chalk.size();\n int i=0;\n long long
brightworld
NORMAL
2024-09-02T15:07:26.421162+00:00
2024-09-02T15:07:26.421194+00:00
4
false
# Code\n```cpp []\nclass Solution {\npublic:\n int chalkReplacer(vector<int>& chalk, int k) {\n int n = chalk.size();\n int i=0;\n long long sum = 0;\n for(auto it : chalk){\n sum += it;\n }\n\n int round = k%sum;\n while(i<n){\n if(round>=chalk...
2
0
['C++']
0
find-the-student-that-will-replace-the-chalk
Python Solution
python-solution-by-pushkar91949-cgnj
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
Pushkar91949
NORMAL
2024-09-02T14:36:34.006291+00:00
2024-09-02T14:36:34.006323+00:00
29
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)$$ --...
2
0
['Array', 'Python3']
2
find-the-student-that-will-replace-the-chalk
Easy Solution in java
easy-solution-in-java-by-nishapandey4-i5qh
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nUsed the prefix sum and
NishaPandey4
NORMAL
2024-09-02T13:12:37.873081+00:00
2024-09-02T13:12:37.873128+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUsed the prefix sum and modulo reduction approach to efficiently determine the student who will need chalk next.\n# Complexity\n- Time complexity:\n<!-- Add your time ...
2
0
['Java']
0
find-the-student-that-will-replace-the-chalk
Who Runs Out of Chalk First? An O(n) Solution C++
who-runs-out-of-chalk-first-an-on-soluti-ni5m
Intuition\n Describe your first thoughts on how to solve this problem. \n- The problem involves a circular usage of chalk by students. The challenge is to deter
ROHAN_SHETTY
NORMAL
2024-09-02T13:04:56.991203+00:00
2024-09-02T13:04:56.991229+00:00
20
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- The problem involves a circular usage of chalk by students. The challenge is to determine which student will run out of chalk when given a certain amount, k. Each student uses a specific amount of chalk from the chalk array, and they us...
2
0
['C++']
0
find-the-student-that-will-replace-the-chalk
Solution
solution-by-neelgohel-0j66
Approach\n\n1. Calculate Total Chalk Needed:\nIterate through the chalk array and sum up the chalk required by each student to complete one full cycle of the pr
NeelGohel
NORMAL
2024-09-02T11:54:19.512998+00:00
2024-09-02T11:54:19.513031+00:00
11
false
# Approach\n\n1. Calculate Total Chalk Needed:\nIterate through the chalk array and sum up the chalk required by each student to complete one full cycle of the problem-solving process. Let\'s denote this sum as totalChalk.\n\n2. Determine Effective Chalk Usage:\nCompute the remaining chalk after accounting for all comp...
2
0
['Java']
0
find-the-student-that-will-replace-the-chalk
Java Simple Solution
java-simple-solution-by-shree_govind_jee-gjdt
Complexity\n- Time complexity:O(2*n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
Shree_Govind_Jee
NORMAL
2024-09-02T07:53:55.682694+00:00
2024-09-02T07:53:55.682769+00:00
81
false
# Complexity\n- Time complexity:$$O(2*n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n int len = chalk.length;\n\n ...
2
0
['Array', 'Math', 'Binary Search', 'Simulation', 'Prefix Sum', 'Java']
0
find-the-student-that-will-replace-the-chalk
easy c++ solution |🔥🔥
easy-c-solution-by-sarthakgoel84-i0d1
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
sarthakgoel84
NORMAL
2024-09-02T07:40:34.987655+00:00
2024-09-02T07:40:34.987693+00:00
23
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)$$ --...
2
0
['C++']
0
find-the-student-that-will-replace-the-chalk
Simplest Approach || Brute Force || T.C=O(n) || S.C=O(1)
simplest-approach-brute-force-tcon-sco1-q25nr
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem revolves around determining which student will run out of chalk first after
prayashbhuria931
NORMAL
2024-09-02T06:51:03.871512+00:00
2024-09-02T06:51:03.871542+00:00
23
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem revolves around determining which student will run out of chalk first after a large number of rounds. Initially, it might seem that we need to simulate each round, but this would be inefficient given the large possible value o...
2
0
['Array', 'Simulation', 'C++']
0
find-the-student-that-will-replace-the-chalk
first approach TLE inuition lene mein laga thoda help discussion is a gr8 platform :D
first-approach-tle-inuition-lene-mein-la-3n0t
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
yesyesem
NORMAL
2024-09-02T06:34:45.475474+00:00
2024-09-02T06:34:45.475504+00:00
6
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)$$ --...
2
0
['C++']
0
find-the-student-that-will-replace-the-chalk
Javascript beginner friendly solution with explanation.
javascript-beginner-friendly-solution-wi-ppdr
Intuition\n Describe your first thoughts on how to solve this problem. \nThis problem involves determining which student will be the first to run out of chalk a
sajjan_shivani
NORMAL
2024-09-02T05:32:28.426192+00:00
2024-09-02T05:32:28.426224+00:00
49
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis problem involves determining which student will be the first to run out of chalk after a given total supply (k) is distributed in a round-robin fashion among the students. Each student in the chalk array requires a certain amount of ...
2
0
['JavaScript']
0
find-the-student-that-will-replace-the-chalk
Easy C++ Solution
easy-c-solution-by-pradeepredt-a2td
Intuition\n Describe your first thoughts on how to solve this problem. \nReduce the problem by eliminating complete rounds of chalk consumption, then find the f
pradeepredt
NORMAL
2024-09-02T04:46:23.983486+00:00
2024-09-02T04:46:23.983518+00:00
24
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nReduce the problem by eliminating complete rounds of chalk consumption, then find the first student who can\'t use the remaining chalk.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n-> Calculate the total chalk con...
2
0
['Array', 'Simulation', 'C++']
0
find-the-student-that-will-replace-the-chalk
beats 100 % users using prefix sum method.............
beats-100-users-using-prefix-sum-method-v7l6l
\n\n# Code\njava []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n return getChalkReplacer(chalk, k);\n }\n public int get
rudramanikanta02
NORMAL
2024-09-02T04:43:41.528233+00:00
2024-09-02T04:43:41.528261+00:00
16
false
\n\n# Code\n```java []\nclass Solution {\n public int chalkReplacer(int[] chalk, int k) {\n return getChalkReplacer(chalk, k);\n }\n public int getChalkReplacer(int[] chalk, int remaining_chalk) {\n int chalk_sum = 0;\n for (int i = 0; i < chalk.length; i++) {\n chalk_sum += cha...
2
0
['Java']
0