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
stone-game-iv
Simple DP solution(O(n*sqrt(n))) with explaination (Java)
simple-dp-solutiononsqrtn-with-explainat-oej6
This quesion is actually about the best strategy. \nFirstly, let us write down the first couple of cases:\n\n|Stone | Alice can win by some strategy| Explain|\n
troydad
NORMAL
2020-07-12T01:56:53.236601+00:00
2020-07-13T17:41:10.133648+00:00
99
false
This quesion is actually about the best strategy. \nFirstly, let us write down the first couple of cases:\n\n|Stone | Alice can win by some strategy| Explain|\n|---|---|---|\n|1|true|Trivial|\n|2|false|Alice can only take 1 and bob win|\n|3|true|Alice 1, bob 1, alice win|\n|4|true|Alice 4|\n|5|false|Alice take 1 or 4, ...
2
1
['Dynamic Programming']
1
stone-game-iv
DP solution in Python
dp-solution-in-python-by-k0ush1k-alrl
\nclass Solution:\n def winnerSquareGame(self, n: int) -> bool:\n dp = [0 for i in range(n+1)]\n dp[0] = 0\n dp[1] = 1\n for i in
k0ush1k
NORMAL
2020-07-11T17:06:42.851752+00:00
2020-07-11T17:06:42.851797+00:00
49
false
```\nclass Solution:\n def winnerSquareGame(self, n: int) -> bool:\n dp = [0 for i in range(n+1)]\n dp[0] = 0\n dp[1] = 1\n for i in range(2,n+1):\n x = int(math.sqrt(i))\n for j in range(1,x+1):\n if dp[i-j*j] == 0:\n dp[i] = 1\n ...
2
0
[]
0
stone-game-iv
[Python] O(n*sqrt*(n)) time O(n) space - DP solution
python-onsqrtn-time-on-space-dp-solution-ie90
Explanation: First, we compute all square numbers, so we know which numbers are square numbers.\n Then we have the DP table (denoted as C):\n
theleetman
NORMAL
2020-07-11T16:07:13.401595+00:00
2020-07-11T16:07:13.401648+00:00
198
false
Explanation: First, we compute all square numbers, so we know which numbers are square numbers.\n Then we have the DP table (denoted as C):\n C[i][b] - i is current number of stones in the pile\n b is 0 or 1 (player 0 or player 1, defined as ALICE or BOB)\n\n ...
2
0
[]
0
stone-game-iv
[C++] DP Solution (5 Lines Clean Code)
c-dp-solution-5-lines-clean-code-by-appl-14za
\n bool winnerSquareGame(int n) {\n vector<bool> dp(n + 1, false); \n for(int i = 1; i <= n; i++)\n for(int j = 1; j * j <= i; j++){
applefanboi
NORMAL
2020-07-11T16:05:04.855051+00:00
2020-07-11T16:20:11.572024+00:00
208
false
```\n bool winnerSquareGame(int n) {\n vector<bool> dp(n + 1, false); \n for(int i = 1; i <= n; i++)\n for(int j = 1; j * j <= i; j++){\n dp[i] = !dp[i - (j * j)];\n if(dp[i]) break;\n }\n return dp[n];\n }\n\n```
2
0
['Dynamic Programming', 'C', 'C++']
0
stone-game-iv
easy dp c++
easy-dp-c-by-diveyk-7dj5
\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n vector<int> dp(n+1);\n for(int i=1; i<=n; ++i) {\n for(int j=1; j*j<=
diveyk
NORMAL
2020-07-11T16:02:25.207323+00:00
2020-07-11T16:02:25.207354+00:00
175
false
```\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n vector<int> dp(n+1);\n for(int i=1; i<=n; ++i) {\n for(int j=1; j*j<=i; ++j)\n dp[i]|=!dp[i-j*j];\n }\n return dp[n];\n }\n};\n```
2
1
[]
1
stone-game-iv
Game theory + DP, Simple solution | Recursive | My screen recording
game-theory-dp-simple-solution-recursive-yuwa
\nclass Solution {\npublic:\n \n int dp[100009];\n \n // check if a number if a square or not\n bool isSq(int x) {\n int y = sqrt(x);\n
rachilies
NORMAL
2020-07-11T16:01:38.315770+00:00
2020-07-11T23:00:31.140163+00:00
346
false
```\nclass Solution {\npublic:\n \n int dp[100009];\n \n // check if a number if a square or not\n bool isSq(int x) {\n int y = sqrt(x);\n return (y * y == x);\n }\n \n bool flag = false;\n \n bool winnerSquareGame(int n) {\n // this step is run only once to initialize...
2
0
[]
0
stone-game-iv
Java 5 lines
java-5-lines-by-mayank12559-di9d
\npublic boolean winnerSquareGame(int n) {\n boolean []dp = new boolean[n+1];\n for(int i=1; i<=n; i++)\n for(int j = (int)Math.sqrt(i)
mayank12559
NORMAL
2020-07-11T16:00:53.552469+00:00
2020-07-11T16:00:53.552544+00:00
298
false
```\npublic boolean winnerSquareGame(int n) {\n boolean []dp = new boolean[n+1];\n for(int i=1; i<=n; i++)\n for(int j = (int)Math.sqrt(i); !dp[i] && j >= 1; j--)\n dp[i] = !dp[i -j*j];\n return dp[n];\n }\n```
2
0
[]
1
stone-game-iv
DP and Math, with explanation! O(N *square_root(N)) / O(N)
dp-and-math-with-explanation-on-square_r-08tr
Intuition\n Describe your first thoughts on how to solve this problem. \nBuilding the solution from the start 0 to end N. Alice tries her best to make Bob lose
Kai_XD
NORMAL
2024-08-08T03:43:37.414441+00:00
2024-08-08T03:43:37.414467+00:00
26
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBuilding the solution from the start 0 to end N. Alice tries her best to make Bob lose by picking some square number of stone which makes Bob in a losing state.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUse D...
1
0
['Python3']
0
stone-game-iv
C++ Code
c-code-by-lucifer_2214-5c6k
class Solution {\npublic:\n bool winnerSquareGame(int n) {\n vector dp(n + 1, false);\n for (int i = 1; i <= n; ++i) {\n for (int k
lucifer_2214
NORMAL
2024-07-03T04:21:30.317189+00:00
2024-07-03T04:21:30.317227+00:00
28
false
class Solution {\npublic:\n bool winnerSquareGame(int n) {\n vector<bool> dp(n + 1, false);\n for (int i = 1; i <= n; ++i) {\n for (int k = 1; k * k <= i; ++k) {\n if (!dp[i - k * k]) {\n dp[i] = true;\n break;\n }\n ...
1
0
['C++']
0
stone-game-iv
Beats 100%🔥|| DP🔥|| Memoization🔥|| easy ✅
beats-100-dp-memoization-easy-by-priyans-kdau
Simple if current index is false than every perfect square+current index will be true because Alice will put bob on a losing position.\n# 1st Method\n\nclass So
priyanshu1078
NORMAL
2024-01-11T17:22:51.774935+00:00
2024-01-11T17:22:51.774969+00:00
450
false
Simple if current index is **false** than every perfect square+current index will be **true** because Alice will put bob on a losing position.\n# 1st Method\n```\nclass Solution {\n public boolean winnerSquareGame(int n) {\n boolean dp[]=new boolean[n+1];\n for(int i=0;i<=n;i++){\n if(dp[i])...
1
0
['Dynamic Programming', 'Memoization', 'Java']
0
stone-game-iv
C++
c-by-ankita2905-ra6f
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
Ankita2905
NORMAL
2023-10-03T13:07:59.097657+00:00
2023-10-03T13:07:59.097677+00:00
161
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['C++']
0
stone-game-iv
C++
c-by-ankita2905-rwi1
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
Ankita2905
NORMAL
2023-10-03T13:07:56.945432+00:00
2023-10-03T13:07:56.945457+00:00
44
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['C++']
0
stone-game-iv
A simple solution for C
a-simple-solution-for-c-by-zsbxp-gp8s
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
zsbxp
NORMAL
2023-06-14T16:00:23.205700+00:00
2023-06-14T16:00:23.205718+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. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$...
1
0
['C']
1
stone-game-iv
✅✅ C++ || JAVA || GO || easy & simple
c-java-go-easy-simple-by-tamim447-yd31
C++ Solution:\n\n\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n vector<bool>dp(n+1, 0);\n for(int i=1; i<=n; i++) {\n
tamim447
NORMAL
2022-09-22T19:54:05.315329+00:00
2022-11-01T16:36:54.792084+00:00
321
false
**C++ Solution:**\n\n```\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n vector<bool>dp(n+1, 0);\n for(int i=1; i<=n; i++) {\n for(int j=1; j*j<=i; j++) {\n if(!dp[i-j*j]) {\n dp[i] = true;\n break;\n }\n ...
1
0
['C', 'Java', 'Go']
1
stone-game-iv
Beats 100% Memory and 91% Speed | Python | DP
beats-100-memory-and-91-speed-python-dp-yf9qr
\n\n\n```\nclass Solution:\n def winnerSquareGame(self, n: int) -> bool:\n dp=[False](n+1)\n w=[]\n for i in range(1,int((n).5)+1):\n
abhishekm-001
NORMAL
2022-08-23T09:22:17.077158+00:00
2022-08-23T09:35:15.632920+00:00
111
false
![image](https://assets.leetcode.com/users/images/1c6b8378-92a3-4634-afed-8ce0567f888f_1661247210.7316856.png)\n![image](https://assets.leetcode.com/users/images/ca8b3d69-e4bd-4be8-9721-bb2b793721cf_1661247128.0921648.png)\n\n```\nclass Solution:\n def winnerSquareGame(self, n: int) -> bool:\n dp=[False]*(n+1...
1
0
['Dynamic Programming', 'Python']
0
stone-game-iv
C++ Tabulation + Memoization
c-tabulation-memoization-by-omhardaha1-2fl8
Tabulation \n\nbool winnerSquareGame(int n)\n{\n vector<int> dp(n + 1, -1);\n dp[0] = false;\n for (int k = 1; k <= n; k++)\n {\n bool f = 0;
omhardaha1
NORMAL
2022-06-24T19:34:58.189392+00:00
2022-06-24T19:34:58.189438+00:00
156
false
# Tabulation \n```\nbool winnerSquareGame(int n)\n{\n vector<int> dp(n + 1, -1);\n dp[0] = false;\n for (int k = 1; k <= n; k++)\n {\n bool f = 0;\n for (int i = sqrt(n); i >= 1; i--)\n {\n if (i * i <= k)\n {\n if (!dp[k - i * i])\n {...
1
0
['Dynamic Programming', 'Recursion', 'Memoization', 'C']
1
stone-game-iv
C++|| EASY TO UNDERSTAND || 3 Approaches || Memoization+Tabulaton
c-easy-to-understand-3-approaches-memoiz-rhgq
Memoization\n\nclass Solution {\npublic:\n bool fun(int n,vector<int> &memo)\n {\n bool res=false;\n if(memo[n]!=-1)\n return mem
aarindey
NORMAL
2022-04-12T17:44:07.161665+00:00
2022-04-12T17:52:51.631486+00:00
75
false
**Memoization**\n```\nclass Solution {\npublic:\n bool fun(int n,vector<int> &memo)\n {\n bool res=false;\n if(memo[n]!=-1)\n return memo[n];\n for(int i=1;i*i<=n;i++)\n {\n res=res|(!fun(n-i*i,memo));\n }\n return memo[n]=res;\n }\n bool winne...
1
0
[]
0
stone-game-iv
Dynamic Programming | TC: O(n * sqrt(n)) SC: O(n)
dynamic-programming-tc-on-sqrtn-sc-on-by-emd1
Intution is to find a state where the other player can lose. If such a state exists, the current player can win the game (both players play optimally). We know
sks_15
NORMAL
2022-01-23T12:28:04.803399+00:00
2022-01-23T12:28:04.803433+00:00
50
false
Intution is to find a state where the other player can lose. If such a state exists, the current player can win the game (both players play optimally). We know that in order to maintain these states, we need to do this problem dynamically. \n\nIf we have a state from all the `k` where k ranges from [1, sqrt(i)]. This i...
1
0
['Dynamic Programming', 'C', 'Game Theory']
0
stone-game-iv
very easy solution c++ will understand
very-easy-solution-c-will-understand-by-d2kg0
\nclass Solution {\npublic:\n \n bool stonegame(int n,vector<int> &vec)\n{\n if(n==0)\n return false;\n if(vec[n]!=-1)\n return vec[n];\n \
AdityaAlugani_
NORMAL
2022-01-22T17:57:40.190904+00:00
2022-01-22T17:57:40.190952+00:00
40
false
```\nclass Solution {\npublic:\n \n bool stonegame(int n,vector<int> &vec)\n{\n if(n==0)\n return false;\n if(vec[n]!=-1)\n return vec[n];\n \n for(int i=1;i*i<=n;i++)\n {\n if(!stonegame(n-i*i,vec))\n return vec[n]=true;\n }\n return vec[n]=false;\n}\n bool winnerSquar...
1
0
['Dynamic Programming']
0
stone-game-iv
Detailed explanation with examples using pen and paper || DP
detailed-explanation-with-examples-using-n4yn
Explanation\n\n\n\n\n\nJAVA CODE\n\n\nclass Solution {\n public boolean winnerSquareGame(int n) {\n boolean dp[] = new boolean[n + 1];\n //No s
rachana_raut
NORMAL
2022-01-22T17:02:36.476341+00:00
2022-01-22T17:02:36.476382+00:00
88
false
**Explanation**\n![image](https://assets.leetcode.com/users/images/bea8a566-9830-45ef-9f93-1104dfefdc99_1642870871.860435.jpeg)\n\n![image](https://assets.leetcode.com/users/images/182a7e8b-a652-4828-9332-3be7c82c2018_1642870882.0127468.jpeg)\n\n\n**JAVA CODE**\n\n```\nclass Solution {\n public boolean winnerSquareG...
1
0
['Dynamic Programming', 'Java']
1
stone-game-iv
[C++] Intuitive Solution | DP | Tabulation | Memorization
c-intuitive-solution-dp-tabulation-memor-gw5w
APPROACH : DP Tabulation\n\n Alice wins if he can make Bob lose the game.\n\nAlice plays first :\n\nFor example :\n\nn = 1 ---> Alice picks 1 stone & wins the g
Mythri_Kaulwar
NORMAL
2022-01-22T16:25:34.951361+00:00
2022-01-22T16:25:34.951389+00:00
189
false
**APPROACH : DP Tabulation**\n\n* Alice wins if he can make Bob lose the game.\n\nAlice plays first :\n\n*For example :*\n```\nn = 1 ---> Alice picks 1 stone & wins the game\nn = 2 ---> Alice picks 1 stone, Bob picks one stone, Alice is left with nothing so he loses.\nn = 3 ---> Alice picks 1 stone, Bob picks 1 stone, ...
1
0
['Dynamic Programming', 'Memoization', 'C', 'C++']
0
stone-game-iv
Easy C++ solution
easy-c-solution-by-kunal_sihare-w9hv
\n bool winnerSquareGame(int n) {\n vector<bool>dp(n+1,false);\n if(n==1)\n return true;\n if(n==2)\n return false;\n
Kunal_Sihare
NORMAL
2022-01-22T15:26:08.468127+00:00
2022-01-22T15:26:08.468168+00:00
46
false
```\n bool winnerSquareGame(int n) {\n vector<bool>dp(n+1,false);\n if(n==1)\n return true;\n if(n==2)\n return false;\n dp[0]=false;\n dp[1]=true;\n dp[2]=false;\n for(int i=3;i<=n;i++)\n {\n for(int k=1;k*k<=i;k++)\n {...
1
0
['Dynamic Programming', 'C']
0
stone-game-iv
C++ : 3 Accepted Solutions with clear explanation
c-3-accepted-solutions-with-clear-explan-3e4d
Points to consider:\n\nA. Zero is a losing position.\nB. A state is a WinningState if at least one of the positions that can be obtained from this position by a
MayankAtLeetcode
NORMAL
2022-01-22T15:02:28.008668+00:00
2022-01-22T15:03:06.102746+00:00
42
false
Points to consider:\n\nA. Zero is a losing position.\nB. A state is a WinningState if at least one of the positions that can be obtained from this position by a single move is a LosingSate.\nC. A state is a LosingState if every position that can be obtained from this position by a single move is a WinningState.\n\n**1s...
1
0
['Dynamic Programming', 'C']
0
stone-game-iv
C++ solution with inline comments
c-solution-with-inline-comments-by-rix23-ke3o
The idea is to keep track of the game states. A state is a winner state if we can reach a looser state.\nTime complexity: O(n^1.5)\nSpace complexity: O(n)\n\n``
Rix2323
NORMAL
2022-01-22T14:50:02.492948+00:00
2022-01-22T15:00:51.535938+00:00
26
false
The idea is to keep track of the game states. A state is a winner state if we can reach a looser state.\nTime complexity: O(n^1.5)\nSpace complexity: O(n)\n\n````\nclass Solution { \npublic: \n bool winnerSquareGame(int n) {\n vector<int> square;\n ...
1
0
[]
0
stone-game-iv
Memoization | Python| Readable | Detailed Comments and naming | No crazy tricks
memoization-python-readable-detailed-com-wqst
Search all possible moves but memoization saves the day,\nDynamic programming solution also possible, give it a try.\n\nclass Solution(object):\n def winnerS
delcin
NORMAL
2022-01-22T14:19:34.958823+00:00
2022-01-22T14:19:34.958853+00:00
102
false
Search all possible moves but memoization saves the day,\nDynamic programming solution also possible, give it a try.\n```\nclass Solution(object):\n def winnerSquareGame(self, n):\n """\n :type n: int\n :rtype: bool\n """\n starterWins = dict()\n # This dictionary stores the...
1
0
['Recursion', 'Memoization', 'Python']
1
stone-game-iv
C++ | Dp | Fast and easy
c-dp-fast-and-easy-by-dr_strange_10-wcoy
\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n int dp[n+1];\n dp[0] = false;\n for(int i = 1;i<=n;i++)\n {\n
Dr_Strange_10
NORMAL
2022-01-22T08:21:45.590446+00:00
2022-01-22T08:21:45.590477+00:00
31
false
```\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n int dp[n+1];\n dp[0] = false;\n for(int i = 1;i<=n;i++)\n {\n dp[i] = false;\n for(int j = 1; j*j<=i;j++)\n {\n if(dp[i - j*j] == false)\n {\n ...
1
0
['Dynamic Programming']
0
stone-game-iv
C++||1-D DP Solution Commented || Based on few test cases ||
c1-d-dp-solution-commented-based-on-few-m6kxj
```\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n \n // Few test cases to build intuition\n // 1 2 3 4 5 6 7 8 9 10 11 1
Kishan_Srivastava
NORMAL
2022-01-22T08:17:15.906240+00:00
2022-01-22T08:17:15.906266+00:00
32
false
```\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n \n // Few test cases to build intuition\n // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n // T F T T F T F T T F T F T T F T F T T F\n \n // dp[i] simply means if no. of stones are i\n ...
1
0
['Dynamic Programming']
0
stone-game-iv
C++ | DP
c-dp-by-chikzz-m5av
PLEASE UPVOTE IF U LIKE MY SOLUTION\n\n\nclass Solution {\n bool dp[100001];\npublic:\n bool winnerSquareGame(int n) {\n \n if(n==0)return 0
chikzz
NORMAL
2022-01-22T07:52:46.732159+00:00
2022-01-22T07:52:46.732204+00:00
72
false
**PLEASE UPVOTE IF U LIKE MY SOLUTION**\n\n```\nclass Solution {\n bool dp[100001];\npublic:\n bool winnerSquareGame(int n) {\n \n if(n==0)return 0;\n \n if(dp[n])return 1;\n \n bool f=0;\n for(int i=1;i*i<=n;i++)\n {\n f|=(!winnerSquareGame(n-i*...
1
0
['Dynamic Programming']
0
stone-game-iv
Easy solution || Dynamic Programming || Comments
easy-solution-dynamic-programming-commen-zz96
\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n // accumulate all perfect squares less than n\n vector<int> squares;\n fo
utsavslife
NORMAL
2022-01-22T07:50:09.347843+00:00
2022-01-22T07:50:09.347872+00:00
42
false
```\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n // accumulate all perfect squares less than n\n vector<int> squares;\n for(int i=1; i*i<=n; i++){\n squares.push_back(i*i);\n }\n \n // create a dp in which ith position\n // stores the posbl...
1
0
[]
0
stone-game-iv
Simple DP with explanation
simple-dp-with-explanation-by-as468579-be8p
\n\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n vector<bool>dp (n+1, true);\n\t\t// Stores the encountered perfect square numbers\n
as468579
NORMAL
2022-01-22T07:37:19.276853+00:00
2022-01-22T07:38:18.842419+00:00
51
false
```\n\nclass Solution {\npublic:\n bool winnerSquareGame(int n) {\n vector<bool>dp (n+1, true);\n\t\t// Stores the encountered perfect square numbers\n vector<int> squares;\n squares.push_back(1);\n \n\t\t// Since Alice and Bob are symmetric, they have the same strategy\n\t\t// That is ch...
1
0
['Dynamic Programming', 'C++']
0
stone-game-iv
Easy Explanation C++ solution
easy-explanation-c-solution-by-mikki123-opg0
We are checking if in our first move we can remove a square from number such that the resultant number obtained is always losing irrespective of the number remo
mikki123
NORMAL
2022-01-22T06:40:36.748731+00:00
2022-01-22T06:45:37.452196+00:00
35
false
We are checking if in our first move we can remove a square from number such that the resultant number obtained is always losing irrespective of the number removed, so we created a boolean array to get outcome for different numbers. \nTC= O(N^1.5)\nSC=O(N)\n\n```\n bool winnerSquareGame(int n) {\n vector<bool...
1
0
[]
1
shortest-impossible-sequence-of-rolls
[Java/C++/Python] One Pass, O(K) Space
javacpython-one-pass-ok-space-by-lee215-qw7w
Intuition\nFor the first number, it could be any number from 1 to k.\nSo my intuition is to check the first occurrence of all number from 1 to k.\n\n\n# Explana
lee215
NORMAL
2022-07-23T16:00:50.948543+00:00
2022-07-23T16:00:50.948598+00:00
8,204
false
# **Intuition**\nFor the first number, it could be any number from 1 to k.\nSo my intuition is to check the first occurrence of all number from 1 to k.\n<br>\n\n# **Explanation**\nWe check the first occurrences of all number from `A[0]`.\nAssume `A[i]` is the rightmost one among them,\nwhich is the first occurrence of ...
283
2
['C', 'Python', 'Java']
37
shortest-impossible-sequence-of-rolls
C++ | O(N) | SIMPLE TO UNDERSTAND
c-on-simple-to-understand-by-iamcoderrr-zchl
\n It looks like a very heavy Question but believes me It is Not,\n It may be difficult for you to understand why it is Working but, DRY RUN for 1-2 times and
IAmCoderrr
NORMAL
2022-07-23T16:01:30.827872+00:00
2022-07-23T17:46:23.716915+00:00
3,819
false
\n It looks like a very heavy Question but believes me It is Not,\n It may be difficult for you to understand why it is Working but, DRY RUN for 1-2 times and you will understand,\n \n LOGIC:\n First, I found the number which had the last occurrence in rolls means the first point where all the elements are...
123
3
[]
19
shortest-impossible-sequence-of-rolls
Count Subarrays with All Dice
count-subarrays-with-all-dice-by-votruba-scer
\nFor a sequence of size 1, all k dice must appear in rolls.\nFor a sequence of size 2, all k dice must appear after all k dice appear in rolls.\n... and so on.
votrubac
NORMAL
2022-07-23T16:01:26.981486+00:00
2022-07-23T16:17:44.912050+00:00
3,101
false
\nFor a sequence of size 1, all `k` dice must appear in `rolls`.\nFor a sequence of size 2, all `k` dice must appear after all `k` dice appear in `rolls`.\n... and so on.\n \nSo, we go through `rolls` and count unique dice.\n \nWhen we have all `k` dice, we increase the number of sequences `seq` and reset the counte...
81
0
['C', 'Java']
10
shortest-impossible-sequence-of-rolls
Easy To Understand || Java Solution || O(n) || With Explanation || With Question Explain
easy-to-understand-java-solution-on-with-80l5
Since i found it difficult to understand the question in the first go, so we will begin from understanding the question.\n\n#### Understanding the question:\n\n
Utkarsh_09
NORMAL
2022-07-23T18:05:20.077794+00:00
2022-07-23T18:06:09.508991+00:00
1,035
false
Since i found it difficult to understand the question in the first go, so we will begin from understanding the question.\n\n#### Understanding the question:\n\nIn our question we are given an **integer array rolls** where **rolls[i] is the result of i\'th roll**. **We have a dice which has k sides number from 1 to k(in...
49
0
['Java']
12
shortest-impossible-sequence-of-rolls
Greedy | Easy To Understand | With Approach
greedy-easy-to-understand-with-approach-u2uwr
Approach\n\nThe idea is if you\'re given that you can create a L length array of all permutation of k numbers, with atleast M length of given array used from th
codeanzh
NORMAL
2022-07-23T16:02:26.550907+00:00
2022-07-23T18:52:12.102453+00:00
1,397
false
**Approach**\n\nThe idea is if you\'re given that you can create a L length array of all permutation of k numbers, with atleast M length of given array used from the begining, then if you do not find all the k numbers after this m length then L + 1 length can not be created.\n\n**Let me elaborate**\nThink of it a bit r...
27
2
['Greedy', 'C', 'Python']
6
shortest-impossible-sequence-of-rolls
logic and catch behind that five line code
logic-and-catch-behind-that-five-line-co-6c18
so basically we have to make sure that of size 1,2,3,4...k and numbers from[1,2,3,4,.....k] we have every possible permutation.so how will we solve that,\nlet s
karna001
NORMAL
2022-07-23T19:01:54.848059+00:00
2022-07-24T07:03:27.115785+00:00
633
false
so basically we have to make sure that of size 1,2,3,4...k and numbers from[1,2,3,4,.....k] we have every possible permutation.so how will we solve that,\nlet say for size 2 we have to find out for k =3, so what are all the combinations, [1,1],[1,2] ,[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]....since there are 9 cases ...
26
0
['C', 'Ordered Set']
9
shortest-impossible-sequence-of-rolls
C++ | Easy to understand | CPP code
c-easy-to-understand-cpp-code-by-sach400-a7o9
\n \n int shortestSequence(vector & rolls, int k) {\n int n=rolls.size();\n set st;\n int ans=1;\n \n for(int i=0;i<n;i++)
sach4008
NORMAL
2022-07-23T16:33:20.099244+00:00
2022-07-23T16:33:37.619020+00:00
861
false
\n \n int shortestSequence(vector<int> & rolls, int k) {\n int n=rolls.size();\n set<int> st;\n int ans=1;\n \n for(int i=0;i<n;i++){\n st.insert(rolls[i]);\n \n if(st.size()==k){\n\t\t\t\t// we are updating our ans as we our forming all sub-sequenc...
12
1
['Greedy', 'C', 'Ordered Set', 'C++']
7
shortest-impossible-sequence-of-rolls
C++ || 100% faster || 100% less memory || Full Explanation with Intuition.
c-100-faster-100-less-memory-full-explan-dcjh
\n\n\nLet\'s start by building the intuition around the problem,\n\nObservation:\nSo, if we want to build a sequence of size 1. Then all the possible ways are {
AniTheSin
NORMAL
2022-07-24T09:28:41.066802+00:00
2022-07-24T10:35:33.926025+00:00
373
false
![image](https://assets.leetcode.com/users/images/2560f211-d287-4002-8434-63c588cab631_1658658926.0119214.png)\n\n\nLet\'s start by building the intuition around the problem,\n\n**Observation:**\nSo, if we want to build a sequence of size 1. Then all the possible ways are **{1}, {2}, {3}, {4}**.\nSimilarly, if we want ...
11
0
['Ordered Set']
1
shortest-impossible-sequence-of-rolls
[Python O(n) 1 pass] Explanation | Intuition | Code
python-on-1-pass-explanation-intuition-c-9di0
Question\nWe have to find the smallest length such that there exists at least one subsequence of that length which can not be formed by the given array.\n\nIntu
surajajaydwivedi
NORMAL
2022-07-23T16:02:28.878783+00:00
2022-07-23T16:45:56.702241+00:00
548
false
**Question**\nWe have to find the smallest length such that there exists at least one subsequence of that length which can not be formed by the given array.\n\n**Intuition**\nLets say **magically** we know that all the subsequence of length x-1 can be formed between index *i->len(rolls)-1* (both inclusive).\nWe need to...
10
1
['Python']
0
shortest-impossible-sequence-of-rolls
Greedy solution [EXPLAINED]
greedy-solution-explained-by-r9n-ku0p
IntuitionFind the shortest sequence that cannot be formed, we observe that once all dice values (1 to k) are used in a subsequence, it is impossible to extend b
r9n
NORMAL
2024-12-19T02:52:26.629923+00:00
2024-12-19T02:52:26.629923+00:00
36
false
# Intuition\nFind the shortest sequence that cannot be formed, we observe that once all dice values (1 to k) are used in a subsequence, it is impossible to extend beyond sequences of that length using the current rolls.\n\n# Approach\nKeep adding dice rolls to a set until it contains all numbers from 1 to k, increment ...
8
0
['Array', 'Hash Table', 'Greedy', 'C#']
0
shortest-impossible-sequence-of-rolls
C++ | Detailed and easy to understand with diagram
c-detailed-and-easy-to-understand-with-d-o3io
1. Whats being asked?\nIn simple words the question is asking for what minimum length L, a sequence of possible dice moves of length L is not possible. This als
WTEF_adititiwari02
NORMAL
2022-07-25T17:25:46.394092+00:00
2022-07-26T17:21:59.128368+00:00
533
false
#### 1. Whats being asked?\nIn simple words the question is asking for what minimum length L, a sequence of possible dice moves of length L is not possible. This also mean that for length < L, all possible dice moves of that length are allowed.\n\n#### 2. Brute force approach\nAfter being clear about what is being aske...
8
0
['C']
1
shortest-impossible-sequence-of-rolls
C++ | Easy | Full Explains
c-easy-full-explains-by-nitin23rathod-dlbq
We can look at the examples and find out the algorithm:\n\nInput: rolls = [4,2,1,2,3,3,2,4,1], k = 4:\n\n\n\nOutput: 2 , because only 1 level is fully filled\n\
nitin23rathod
NORMAL
2022-07-23T16:00:35.027869+00:00
2022-07-23T16:25:37.072223+00:00
573
false
We can look at the examples and find out the algorithm:\n\nInput: rolls = [4,2,1,2,3,3,2,4,1], k = 4:\n\n![image](https://assets.leetcode.com/users/images/c69abb0c-9780-4e2f-aec0-12798bb84744_1658593127.0967429.png)\n\n**Output: 2 , because only 1 level is fully filled**\n\n**Algorithm:**\n* iterate through rolls\n* ev...
8
1
['C']
1
shortest-impossible-sequence-of-rolls
(My thought process during contest Explained) and clean cpp code using map.
my-thought-process-during-contest-explai-qn2a
My intution for this solution was that we will be able to compute permutaion of any particular size when we will have that much basket of number from 1 to k in
Srivaliii
NORMAL
2022-07-23T18:11:22.771646+00:00
2022-07-24T09:36:03.840234+00:00
308
false
My intution for this solution was that we will be able to compute permutaion of any particular size when we will have that much basket of number from 1 to k in continous order.\nex: [1, 2, 3, 4, 1, 2, 3, 4] \nhere we can generate all permuation of two size because we can pick one element from first basket (index 0 to 3...
6
0
['C++']
2
shortest-impossible-sequence-of-rolls
c++ easy short and concise
c-easy-short-and-concise-by-abhay1707-1w09
``` \nint shortestSequence(vector& rolls, int k) {\n int ans=0,i;\n int n=size(rolls);\n unordered_mapm;\n for(i=n-1; i>=0; i--){
abhay1707
NORMAL
2022-07-23T16:08:11.096720+00:00
2022-07-23T16:08:11.096757+00:00
206
false
``` \nint shortestSequence(vector<int>& rolls, int k) {\n int ans=0,i;\n int n=size(rolls);\n unordered_map<int,int>m;\n for(i=n-1; i>=0; i--){\n m[rolls[i]]++;\n if(m.size()==k){\n ans++;\n m.clear();\n }\n }\n ...
6
1
[]
1
shortest-impossible-sequence-of-rolls
CPP | Easy
cpp-easy-by-amirkpatna-f61t
\nclass Solution {\npublic:\n \n int shortestSequence(vector<int>& rolls, int k) {\n set<int> st;\n int ans=1;\n for(int x:rolls){\n
amirkpatna
NORMAL
2022-07-23T16:02:39.788070+00:00
2022-07-23T16:02:39.788110+00:00
215
false
```\nclass Solution {\npublic:\n \n int shortestSequence(vector<int>& rolls, int k) {\n set<int> st;\n int ans=1;\n for(int x:rolls){\n if(!st.count(x))st.insert(x);\n if(st.size()==k){\n st.clear();\n ans++;\n }\n }\n ...
6
1
['C++']
0
shortest-impossible-sequence-of-rolls
C++ || SET
c-set-by-ganeshkumawat8740-sjgn
get no of segment which has all [1..k] element\'s of array.\n# Code\n\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n
ganeshkumawat8740
NORMAL
2023-05-24T11:54:45.591370+00:00
2023-05-24T11:54:45.591410+00:00
201
false
get no of segment which has all [1..k] element\'s of array.\n# Code\n```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n unordered_set<int> s;\n int a = 1;\n for(auto &i: rolls){\n s.insert(i);\n if(s.size()==k){\n a++;\n ...
4
0
['Array', 'Hash Table', 'Greedy', 'Ordered Set', 'C++']
1
shortest-impossible-sequence-of-rolls
✅ [C++] O(N) Intuitive approach w/sets
c-on-intuitive-approach-wsets-by-bit_leg-fy1e
This is agruably one of the Easiest-Hard problem. \nWe are asked to find the shortest subsequence which can not be formed from the given array, given that the a
biT_Legion
NORMAL
2022-07-25T04:01:47.925063+00:00
2022-07-25T04:01:47.925108+00:00
116
false
This is agruably one of the Easiest-Hard problem. \nWe are asked to find the shortest subsequence which can not be formed from the given array, given that the array only contains elements from 1 to k. From this, we can think of the fact that if we have exactly one occurance of each element from 1 to k, then it is possi...
4
0
['Greedy', 'C', 'Ordered Set']
0
shortest-impossible-sequence-of-rolls
JAVA using set
java-using-set-by-aditya_jain_2584550188-rpbo
\nclass Solution {\n\tpublic int shortestSequence(int[] arr, int k) {\n\t\tint res = 1;\n\t\tint index = 0;\n\t\twhile (true) {\n\t\t\tint count = 0;\n\t\t\tint
Aditya_jain_2584550188
NORMAL
2022-07-23T17:54:59.012731+00:00
2022-07-23T17:54:59.012774+00:00
96
false
```\nclass Solution {\n\tpublic int shortestSequence(int[] arr, int k) {\n\t\tint res = 1;\n\t\tint index = 0;\n\t\twhile (true) {\n\t\t\tint count = 0;\n\t\t\tint max = 0;\n\t\t\tHashSet<Integer> set = new HashSet<>();\n\t\t\tfor (int i = index; i < arr.length; i++) {\n\t\t\t\tif (set.contains(arr[i]))\n\t\t\t\t\tcont...
3
0
['Java']
0
shortest-impossible-sequence-of-rolls
[c++ / javascript] solution
c-javascript-solution-by-dilipsuthar60-1k2g
\nclass Solution {\npublic:\n int shortestSequence(vector<int>& nums, int k) {\n unordered_set<int>s;\n int n=nums.size();\n int ans=0;\
dilipsuthar17
NORMAL
2022-07-23T17:31:12.159695+00:00
2022-07-23T17:32:13.457529+00:00
121
false
```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& nums, int k) {\n unordered_set<int>s;\n int n=nums.size();\n int ans=0;\n for(int i=0;i<n;i++)\n {\n s.insert(nums[i]);\n if(s.size()==k)\n {\n ans++;\n ...
3
0
['C', 'C++', 'JavaScript']
0
shortest-impossible-sequence-of-rolls
C++ O(n) iterative solution using set
c-on-iterative-solution-using-set-by-ary-wll6
Algorithm -\n\nThe basic idea behind this algorithim is that every sequence of (x) rolls can be obtained be appending every number from 1 to k to all sequences
AryanMalpani
NORMAL
2022-07-23T16:20:02.694331+00:00
2022-07-26T14:48:14.716034+00:00
43
false
# Algorithm -\n\nThe basic idea behind this algorithim is that every sequence of (x) rolls can be obtained be appending every number from 1 to `k` to all sequences of (x-1) rolls \n\neg - Let k be 4. Now the possible sequences for two rolls are as follows. If taken a closer look each column is a number from 1 to k adde...
3
0
[]
1
shortest-impossible-sequence-of-rolls
Easy C++ one pass Solution With Explaination and Approach
easy-c-one-pass-solution-with-explainati-rsal
Intuition and Approach: Suppose if we can make sequences of length 2 till some index \nFor eg, if we can make all sequences of length 2({1,1}{1,2}{1,3}{1,4}{2,1
karan252
NORMAL
2022-07-23T16:03:19.750671+00:00
2022-07-23T16:09:38.169031+00:00
154
false
**Intuition and Approach:** Suppose if we can make sequences of length 2 till some index \nFor eg, if we can make all sequences of length 2({1,1}{1,2}{1,3}{1,4}{2,1}{2,2}{2,3}{2,4}{3,1}{3,2}{3,3}{3,4}{4,1}{4,2}{4,3}{4,4}) till some index m, then to make sequence of length 3 we will need all the numbers to be present af...
3
0
['C', 'C++']
1
shortest-impossible-sequence-of-rolls
[Easy C++] Thinking process
easy-c-thinking-process-by-coding_mess-8ixa
Longest increase sub-sequence should start with some number b/w 1 and k\n2. If there are 2 number and i and j (i < j), if sub-sequence of len x is possible star
coding_mess
NORMAL
2022-07-23T16:02:18.665631+00:00
2022-07-23T16:03:31.064860+00:00
166
false
1. Longest increase sub-sequence should start with some number b/w 1 and k\n2. If there are 2 number and i and j (i < j), if sub-sequence of len x is possible starting with jth element, then it is definitely possible starting with ith but not vice-versa.\n\nExample [1,1,4,3,4,2,1,2,3, 4] k = 4\nLets take i = 4, j = 5\...
3
0
['Ordered Set']
0
shortest-impossible-sequence-of-rolls
Counting groups.
counting-groups-by-akshay_gupta_7-6b6g
Intuition\nPehle 12 ando ko acche se fete. Phir omlate ki jageh tehelka omlate banaayee.\n\n# Approach\nFind first group which have all eleemnts atleast ones. a
akshay_gupta_7
NORMAL
2024-07-09T19:26:50.229110+00:00
2024-07-10T04:17:21.697318+00:00
64
false
# Intuition\nPehle 12 ando ko acche se fete. Phir omlate ki jageh tehelka omlate banaayee.\n\n# Approach\nFind first group which have all eleemnts atleast ones. any extra element in this group won\'t make an extra length group because last element in this group is unique and to make an new subsequence it needs all elem...
2
0
['Java']
0
shortest-impossible-sequence-of-rolls
Easiest approach using map
easiest-approach-using-map-by-aayu_t-454s
Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n
aayu_t
NORMAL
2024-05-28T20:21:59.362160+00:00
2024-05-28T20:21:59.362177+00:00
20
false
# Complexity\n- Time complexity: **O(n)**\n\n- Space complexity: **O(n)**\n\n# Code\n```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n int n = rolls.size();\n int cnt = 0;\n unordered_map<int, int>mp;\n for(auto i: rolls){\n mp[i]++;\n ...
2
0
['Ordered Map', 'C++']
0
shortest-impossible-sequence-of-rolls
C based implementation
c-based-implementation-by-prabhatravi-fcqw
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem asks to find the length of the shortest sequence of rolls that cannot be ta
prabhatravi
NORMAL
2024-04-28T14:58:30.352868+00:00
2024-04-28T14:58:30.352904+00:00
38
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem asks to find the length of the shortest sequence of rolls that cannot be taken from the given rolls array. To solve this problem efficiently, we need to track the frequency of each roll and count how many different rolls have ...
2
0
['C']
1
shortest-impossible-sequence-of-rolls
hint is the best to look for easiest solution
hint-is-the-best-to-look-for-easiest-sol-doxv
Intuition\n Describe your first thoughts on how to solve this problem. \nif i am not getting that any number that many time that i am looking for\n\n# Approach\
Amanr_nitw
NORMAL
2024-03-20T17:44:46.902847+00:00
2024-03-20T17:44:46.902868+00:00
37
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nif i am not getting that any number that many time that i am looking for\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nsimply traverse through rolls array and check the size of map if it is equal to k and increas...
2
0
['Hash Table', 'C++']
0
shortest-impossible-sequence-of-rolls
c++ | easy | short
c-easy-short-by-venomhighs7-r0qi
\n\n# Code\n\nclass Solution {\npublic:\n int shortestSequence(vector<int>& A, int k) {\n int res = 1;\n unordered_set<int> s;\n for (in
venomhighs7
NORMAL
2022-10-25T05:53:35.379216+00:00
2022-10-25T05:53:35.379253+00:00
717
false
\n\n# Code\n```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& A, int k) {\n int res = 1;\n unordered_set<int> s;\n for (int& a : A) {\n s.insert(a);\n if (s.size() == k) {\n res++;\n s.clear();\n }\n }\n ...
2
0
['C++']
0
shortest-impossible-sequence-of-rolls
simple logic, greedy+hashing
simple-logic-greedyhashing-by-ritzverma0-a9v5
->if we can make a subarray of length X with all k elements till index ix ,than the answer will be (X+1) if we can\'t find at least one of the array element af
ritzverma08
NORMAL
2022-09-18T14:59:45.779882+00:00
2022-09-18T14:59:45.779937+00:00
109
false
->if we can make a subarray of length X with all k elements till index ix ,than the answer will be (X+1) if we can\'t find at least one of the array element after the index ix\n->this can be done using set \n\n```\n int n = rolls.size();\n int cur= 1 ; \n set<int>st;\n for(int i = 0;i<n;i++){\...
2
0
['Greedy']
0
shortest-impossible-sequence-of-rolls
Easy Solution in CPP
easy-solution-in-cpp-by-sanket_jadhav-1fqv
```\nclass Solution {\npublic:\n int shortestSequence(vector& rolls, int k) {\n unordered_sets;\n \n int ans=0;\n for(auto ele:ro
Sanket_Jadhav
NORMAL
2022-08-09T17:06:40.713592+00:00
2022-08-09T17:06:40.713634+00:00
61
false
```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n unordered_set<int>s;\n \n int ans=0;\n for(auto ele:rolls){\n s.insert(ele);\n if(s.size()==k){\n ans++;\n s.clear();\n }\n }\n ...
2
0
[]
0
shortest-impossible-sequence-of-rolls
just medium question !!!! just analyze for atleast 10 test cases
just-medium-question-just-analyze-for-at-r23h
```\ndef shortestSequence(self, rolls: List[int], k: int) -> int:\n #what are thoughts coming in mind?\n #lets check for k=5 what are minimum poss
yaswanthkosuru
NORMAL
2022-08-03T09:49:41.727042+00:00
2022-08-08T10:39:36.258930+00:00
100
false
```\ndef shortestSequence(self, rolls: List[int], k: int) -> int:\n #what are thoughts coming in mind?\n #lets check for k=5 what are minimum possible values requrie {1,2,3,4,5} for 1st combination\n #lets check for k=5 what are minimum possible values require {1,2,3,4,5,1,2,3,4,5} is it make sense...
2
0
[]
0
shortest-impossible-sequence-of-rolls
[C++] Masterpiece Solution || O(N) time
c-masterpiece-solution-on-time-by-prosen-lssq
If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nWe are trying to break the
_pros_
NORMAL
2022-08-02T09:04:13.047304+00:00
2022-08-02T09:05:35.354648+00:00
154
false
# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nWe are trying to break the list into max number of groups that consist of [1, k] elements. \nThe length of the group+1 is the combination that is not possible\nclass Solution {\n...
2
0
['Greedy', 'C', 'C++']
0
shortest-impossible-sequence-of-rolls
CPP | JAVA Solutions | O(N) | Using bitset
cpp-java-solutions-on-using-bitset-by-ia-qak1
CPP Solution\n\nTime Complexity : O(N)\nSpace Complexity : O(N)\n\n\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n b
iambharatks
NORMAL
2022-07-26T04:09:28.643115+00:00
2022-07-26T04:09:28.643151+00:00
31
false
**CPP Solution**\n\nTime Complexity : O(N)\nSpace Complexity : O(N)\n\n```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n bitset<100005> b;\n int res = 0,cnt = 0;\n for(int &i: rolls){\n if(b[i] == 0){\n b[i] = 1;\n cnt++...
2
0
['Bit Manipulation']
0
shortest-impossible-sequence-of-rolls
C++ unordered_set
c-unordered_set-by-omhardaha1-x3cx
- if we have all k element together we can make sub seq of size 1.\n# - so count no. of time all k elements are together.\n\nclass Solution {\npublic:\n int
omhardaha1
NORMAL
2022-07-23T19:41:44.763277+00:00
2022-07-23T19:41:44.763317+00:00
47
false
# - if we have all k element together we can make sub seq of size 1.\n# - so count no. of time all k elements are together.\n```\nclass Solution {\npublic:\n int shortestSequence(vector<int> & rolls, int k) {\n \n unordered_set<int> st;\n int ans=1;\n\n for(int i=0;i<rolls.size();i++){\n ...
2
0
['C', 'Ordered Set']
0
shortest-impossible-sequence-of-rolls
10lines C++ code | Concise | Simple | Greedy
10lines-c-code-concise-simple-greedy-by-fm4r2
\n int shortestSequence(vector<int>& rolls, int k) {\n set<int> s;\n int co=0;\n for(auto it:rolls)\n {\n if(s.find(it)=
nm1605
NORMAL
2022-07-23T16:11:59.021184+00:00
2022-07-23T16:15:56.060734+00:00
81
false
```\n int shortestSequence(vector<int>& rolls, int k) {\n set<int> s;\n int co=0;\n for(auto it:rolls)\n {\n if(s.find(it)==s.end()) s.insert(it);\n if(s.size()==k)\n {\n s.clear();\n co++;\n }\n }\n ret...
2
0
['Greedy', 'C++']
1
shortest-impossible-sequence-of-rolls
Very Simple and Easy to Understand C++ Solution - O(n) time complexity
very-simple-and-easy-to-understand-c-sol-dqff
Up Vote if you like the solution\n\nclass Solution {\npublic:\n //ans is 1 + no. of times 1 to k appers in any sequence\n int shortestSequence(vector<int
kreakEmp
NORMAL
2022-07-23T16:02:56.186980+00:00
2022-07-23T16:16:39.817244+00:00
68
false
<b> Up Vote if you like the solution\n```\nclass Solution {\npublic:\n //ans is 1 + no. of times 1 to k appers in any sequence\n int shortestSequence(vector<int>& rolls, int k) {\n int m = 1, n = k, ans = 0;\n unordered_set<int> st;\n for(auto r: rolls){\n tst.insert(r);\n ...
2
0
['C', 'Ordered Set']
0
shortest-impossible-sequence-of-rolls
Python easy understanding solution
python-easy-understanding-solution-by-by-yro6
For example, k = 3, rolls = [1, 1, 2, 2, 3, 1]\nUse a set to record if all possible numbers has appeared at least once.\nIn this case, when iterate to 3 in [1
byroncharly3
NORMAL
2022-07-23T16:02:29.487867+00:00
2022-07-24T03:39:32.920509+00:00
158
false
For example, k = 3, rolls = [1, 1, 2, 2, 3, 1]\nUse a set to record if all possible numbers has appeared at least once.\nIn this case, when iterate to 3 in [1, 1, 2, 2, **3**, 1], all possible numbers (1-3) has appeared at least once,\nso you must at least take 1 number from interval [1, 1, 2, 2, 3], in practice, tak...
2
0
['Ordered Set', 'Python', 'Python3']
0
shortest-impossible-sequence-of-rolls
C++ || Set || Greedy
c-set-greedy-by-akash92-ytjk
Intuition\n Describe your first thoughts on how to solve this problem. \nIf all k numbers exist then we can form all subsequences of length 1.\nAfter this if ag
akash92
NORMAL
2024-07-22T13:36:44.258336+00:00
2024-07-22T13:36:44.258370+00:00
0
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf all k numbers exist then we can form all subsequences of length 1.\nAfter this if again all k numbers exist, then we can form all subseq of length 2.\nAfter this if again all k numbers exist, then we can form all subseq of length 3.\nA...
1
0
['C++']
0
shortest-impossible-sequence-of-rolls
[JavaScript] 2350. Shortest Impossible Sequence of Rolls
javascript-2350-shortest-impossible-sequ-9ibg
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n\n\nFrom Question\n "sequence taken does not have to be consecutive as l
pgmreddy
NORMAL
2023-07-22T13:11:29.649802+00:00
2023-07-22T13:15:35.247136+00:00
45
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n\n```\nFrom Question\n "sequence taken does not have to be consecutive as long as it is in order."\n so order of elements is important\n\nExample 1\n when 1,2,3,4 1,2,3,4 occur in sequence\n then [1,2,3,4] ...
1
0
['JavaScript']
1
shortest-impossible-sequence-of-rolls
Java O(N) tricky Solution
java-on-tricky-solution-by-adarsh2dubey-4u5w
\n\n\n\n\n# To make all combinations of length len of k numbers we need to have numbers 1-k atleast appearing len times in the array :\nExample:\nfor k = 3 len
adarsh2dubey
NORMAL
2022-07-30T11:26:59.870484+00:00
2022-07-30T11:33:03.842485+00:00
99
false
\n\n\n\n\n# To make all combinations of length len of k numbers we need to have numbers 1-k atleast appearing len times in the array :\n**Example**:\nfor k = 3 len = 2\nAll possible sequences :\n=> 1 1, 1 2, 1 3, 2 1, 2 2, 2 3, 3 1, 3 2, 3 3\n to create all those possibilities of arrangements we need to have 1,2,3,1,2,...
1
1
['Java']
0
shortest-impossible-sequence-of-rolls
Simplest Detailed Explanation-Simple Logic
simplest-detailed-explanation-simple-log-eu9r
This problem is actually straightforward.\nAll we need is a little insight into how we form the sequences\n\nSuppose k=3\nLet\'s search for all 1 length sequenc
Kogarashi
NORMAL
2022-07-26T18:12:50.368566+00:00
2022-07-26T18:12:50.368619+00:00
50
false
This problem is actually straightforward.\nAll we need is a little insight into how we form the sequences\n\n**Suppose k=3**\nLet\'s search for all **1 length** sequences\nWe will have the following possible sequences->{1}, {2}, {3}.\nNow suppose in the rolls array we found these sequences , which means we can\'t have ...
1
0
[]
0
shortest-impossible-sequence-of-rolls
One Pass solution
one-pass-solution-by-itsyaswanth-rtb2
\nTime : O(nlogn)\nSpace :O(n)\n\n#define ll long long \nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n set<int>s;\n
itsyaswanth
NORMAL
2022-07-26T17:21:58.644087+00:00
2022-07-26T17:21:58.644191+00:00
37
false
![image](https://assets.leetcode.com/users/images/a8b0a6bc-0542-4796-b383-933cf550311c_1658856049.0645862.jpeg)\nTime : `O(nlogn)`\nSpace :` O(n)`\n```\n#define ll long long \nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n set<int>s;\n ll ans = 0;\n for(ll i=0;i<...
1
0
['Ordered Set']
1
shortest-impossible-sequence-of-rolls
C++/JavaScript || TC:O(N)
cjavascript-tcon-by-pradeeptosarkar-dieu
This problem can be easily solved using a clever use of Set data structure and thinking greedily. Other approaches like DP might not yield the desired results a
pradeeptosarkar
NORMAL
2022-07-25T09:37:41.773103+00:00
2022-07-25T09:37:41.773149+00:00
64
false
This problem can be easily solved using a clever use of Set data structure and thinking greedily. Other approaches like DP might not yield the desired results and will be slower.\n\nThe intution is we need to create sets of complete elements such that all the numbers from 1 to K appear atleast once in such a complete s...
1
0
['Greedy', 'C', 'Ordered Set', 'JavaScript']
0
shortest-impossible-sequence-of-rolls
java - easy & small (sliding window)
java-easy-small-sliding-window-by-zx007j-vcgi
Runtime: 6 ms, faster than 100.00% of Java online submissions for Shortest Impossible Sequence of Rolls.\nMemory Usage: 74.8 MB, less than 80.00% of Java online
ZX007java
NORMAL
2022-07-25T07:02:51.738228+00:00
2022-07-25T07:02:51.738276+00:00
79
false
Runtime: 6 ms, faster than 100.00% of Java online submissions for Shortest Impossible Sequence of Rolls.\nMemory Usage: 74.8 MB, less than 80.00% of Java online submissions for Shortest Impossible Sequence of Rolls.\n```\nclass Solution {\n public int shortestSequence(int[] rolls, int k) {\n int table[] = new int[k...
1
0
['Java']
0
shortest-impossible-sequence-of-rolls
😎Very interesting problem with easy and logical solution// CPP
very-interesting-problem-with-easy-and-l-hztw
\n\n/// EX: rolls= [1,2,3,4, 3,2,4,1, 1,1,2,2,4,3, 2,1]\n// _______ _______ ___________ ___\n// | |
rishi800900
NORMAL
2022-07-24T13:25:59.858684+00:00
2022-07-24T13:55:13.087357+00:00
25
false
![image](https://assets.leetcode.com/users/images/8eb15079-e913-4bd1-8ea8-e73a2b24e1f7_1658669088.5797994.png)\n```\n/// EX: rolls= [1,2,3,4, 3,2,4,1, 1,1,2,2,4,3, 2,1]\n// _______ _______ ___________ ___\n// | | | |\n// set = 1,2,3,4 1,2,3,4 ...
1
0
['Greedy', 'C']
0
shortest-impossible-sequence-of-rolls
[Java/Python/Golang] One pass
javapythongolang-one-pass-by-sahil_77-u37o
Python\n\nclass Solution:\n def shortestSequence(self, rolls, k):\n """\n [4,2,1,2,3,3,2,4,1]\n \n we first find the index of a
sahil_77
NORMAL
2022-07-24T08:22:23.806884+00:00
2022-07-24T08:22:23.806922+00:00
103
false
Python\n```\nclass Solution:\n def shortestSequence(self, rolls, k):\n """\n [4,2,1,2,3,3,2,4,1]\n \n we first find the index of a complete set\n \n i= 4 (first occurence of three) \n \n next we iterate through the i-->len(nums)\n finding the next inde...
1
0
['Ordered Set', 'Python', 'Java', 'Go']
1
shortest-impossible-sequence-of-rolls
A simple interview style explanation
a-simple-interview-style-explanation-by-jyasu
\n\n\n\n\n\n\n\nI post solutions like this on LinkedIn, you can follow me there - https://www.linkedin.com/posts/mayank-singh-1004981a4_shortest-impossible-sequ
mayank17081998
NORMAL
2022-07-24T07:01:04.070261+00:00
2022-07-24T07:01:04.070328+00:00
26
false
![image](https://assets.leetcode.com/users/images/35a28030-4dac-4f11-9288-64074697ae77_1658645886.5772471.png)\n![image](https://assets.leetcode.com/users/images/89552ebd-ea7b-4078-9f74-6cd8ef800ab9_1658645894.2088807.png)\n![image](https://assets.leetcode.com/users/images/6940b633-009d-423b-8848-f308fb1262e1_165864589...
1
0
['C', 'Ordered Set']
0
shortest-impossible-sequence-of-rolls
Java, O(n)|O(k), 3ms
java-onok-3ms-by-vkochengin-2xqe
\npublic int shortestSequence(int[] rolls, int k) {\n\tboolean[] s = new boolean[k+1];\n\tint count = k;\n\tboolean v = true;\n\tint result = 1;\n\tfor(int i:ro
vkochengin
NORMAL
2022-07-24T06:24:14.881073+00:00
2022-07-24T06:24:14.881336+00:00
15
false
```\npublic int shortestSequence(int[] rolls, int k) {\n\tboolean[] s = new boolean[k+1];\n\tint count = k;\n\tboolean v = true;\n\tint result = 1;\n\tfor(int i:rolls){\n\t\tif(s[i]!=v){\n\t\t\ts[i]=v;\n\t\t\tcount--;\n\t\t\tif(count == 0){\n\t\t\t\tresult++;\n\t\t\t\tcount = k;\n\t\t\t\tv=!v;\n\t\t\t}\n\t\t}\n\t}\n\tr...
1
0
[]
0
shortest-impossible-sequence-of-rolls
Greedy Solution using SET
greedy-solution-using-set-by-_v3n0m-2l5u
Iterate untill you make the size of the set equals k this is, you find all the k numbers.\nThere can be two case :\n->If you don\'t find all the k numbers after
_V3N0M
NORMAL
2022-07-24T04:18:00.835594+00:00
2022-10-21T15:05:14.209175+00:00
34
false
Iterate untill you make the size of the set equals k this is, you find all the k numbers.\n*There can be two case :*\n->If you don\'t find all the k numbers after iterating all the numbers \n->If you find all the k numbers before completing the whole iteration, then the current length permutation is fixed that you can ...
1
0
['Greedy', 'C', 'Ordered Set', 'C++']
0
shortest-impossible-sequence-of-rolls
[Python3] hash set
python3-hash-set-by-ye15-6hjs
\n\nclass Solution:\n def shortestSequence(self, rolls: List[int], k: int) -> int:\n ans = 1\n seen = set()\n for x in rolls: \n
ye15
NORMAL
2022-07-24T01:34:38.089234+00:00
2022-07-24T01:34:38.089265+00:00
42
false
\n```\nclass Solution:\n def shortestSequence(self, rolls: List[int], k: int) -> int:\n ans = 1\n seen = set()\n for x in rolls: \n seen.add(x)\n if len(seen) == k: \n ans += 1\n seen.clear()\n return ans\n```
1
1
['Python3']
0
shortest-impossible-sequence-of-rolls
C++ O(n) solution || easy to understand
c-on-solution-easy-to-understand-by-adit-hvq5
Approach : we have to find the shortest impossible sequence that is if dice has all numbers occuring once then the impossible length will be two.\nif all number
aditya0203
NORMAL
2022-07-23T18:06:36.865028+00:00
2022-07-23T18:06:36.865059+00:00
26
false
Approach : we have to find the shortest impossible sequence that is if dice has all numbers occuring once then the impossible length will be two.\nif all numbers are occuring twice when we divide the array then the impossible length will be 3.. and so on. \n\nwith the code itself you will understand the intution.\n\n``...
1
0
['C', 'Ordered Set']
1
shortest-impossible-sequence-of-rolls
Python Solution linear time and space
python-solution-linear-time-and-space-by-vtxh
\nclass Solution:\n def shortestSequence(self, rolls: List[int], k: int) -> int:\n s = set()\n ans = 1\n for r in rolls:\n s.
user6397p
NORMAL
2022-07-23T17:45:49.445043+00:00
2022-07-23T17:46:08.425971+00:00
15
false
```\nclass Solution:\n def shortestSequence(self, rolls: List[int], k: int) -> int:\n s = set()\n ans = 1\n for r in rolls:\n s.add(r)\n if len(s) == k:\n ans += 1\n s = set()\n \n return ans\n```
1
0
[]
0
shortest-impossible-sequence-of-rolls
C++ || Set || Explained With Example || I will not say , it was easy || Thinking Based Q.
c-set-explained-with-example-i-will-not-ruev6
\n // Intuition \n \n // check for this one -> [4,2,1,2,3,3,2,4,1], k = 4\n \n // Take the element till it has at least one occurences of distinc
KR_SK_01_In
NORMAL
2022-07-23T17:45:47.785853+00:00
2022-07-23T17:48:04.709039+00:00
27
false
```\n // Intuition \n \n // check for this one -> [4,2,1,2,3,3,2,4,1], k = 4\n \n // Take the element till it has at least one occurences of distinct k values\n \n // Take a set , we will start inserting the value in the set which have values [ 4 , 2 , 1 , 2 , 3] upto \n // index 4 , \n \n ...
1
0
['C', 'Ordered Set', 'C++']
0
shortest-impossible-sequence-of-rolls
Short & Concise | C++
short-concise-c-by-tusharbhart-va0g
\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n unordered_set<int> s;\n int ans = 1;\n \n for(i
TusharBhart
NORMAL
2022-07-23T16:57:22.376125+00:00
2022-07-23T16:57:22.376151+00:00
24
false
```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n unordered_set<int> s;\n int ans = 1;\n \n for(int i : rolls) {\n s.insert(i);\n if(s.size() == k) s.clear(), ans++;\n }\n return ans;\n }\n};\n```
1
0
['Greedy', 'C', 'Ordered Set']
0
shortest-impossible-sequence-of-rolls
C++ Greedy
c-greedy-by-harem_jutsu-8rmz
We Can Notice That for all sequence of length 1 we need all k numbers once,\nSimilarly for all length 2 sequence we need all k numbers again after we have found
harem_jutsu
NORMAL
2022-07-23T16:50:54.542261+00:00
2022-07-23T16:50:54.542285+00:00
36
false
We Can Notice That for all sequence of length 1 we need all k numbers once,\nSimilarly for all length 2 sequence we need all k numbers again after we have found them already once because\nas we have found out all k elements once again, we can pair them up such that they form every length 2 sequence.\n```\nSay k=4\nnums...
1
0
['Greedy', 'C']
1
shortest-impossible-sequence-of-rolls
Short and Simple Solution
short-and-simple-solution-by-chaturvedip-yxm5
\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n int res=1;\n unordered_set<int> s;\n for(int &i:rolls)
ChaturvediParth
NORMAL
2022-07-23T16:47:44.655008+00:00
2022-07-23T16:47:44.655045+00:00
15
false
```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n int res=1;\n unordered_set<int> s;\n for(int &i:rolls) {\n s.insert(i);\n if(s.size()==k) {\n res++;\n s.clear();\n }\n }\n return res...
1
0
[]
0
shortest-impossible-sequence-of-rolls
C++ One Pass
c-one-pass-by-mandelakalam12364-7r0m
This solution has been taken from @penguinhacker\nWorld class solution\nJust do the dry run and you will understand the logic\nIf you have any confusion, please
mandelakalam12364
NORMAL
2022-07-23T16:20:37.448352+00:00
2022-07-23T16:22:05.875529+00:00
20
false
This solution has been taken from @penguinhacker\nWorld class solution\nJust do the dry run and you will understand the logic\nIf you have any confusion, please comment below\n\nTime Complexity :O(n)\nSpace Complexity : O(k)\n```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n ...
1
0
['C']
0
shortest-impossible-sequence-of-rolls
C++ Easy Intutive , Contest solution
c-easy-intutive-contest-solution-by-thea-s52l
\n First we store all indices corresponding with the number\n Now for len=1 , get minimum indices from (1 to k)\n now for len=2 , (1 to k ) should exist before
TheAkkirana
NORMAL
2022-07-23T16:11:53.999821+00:00
2022-07-23T16:11:53.999848+00:00
29
false
\n* First we store all indices corresponding with the number\n* Now for len=1 , get minimum indices from (1 to k)\n* now for len=2 , (1 to k ) should exist before the last length index \n* now for len=3 , get minimum index from len=2 , and check whether (1 to k ) exist before last index\n* BUT WHY THIS ??\n* len =1 {1,...
1
0
[]
0
shortest-impossible-sequence-of-rolls
Python - Just count complete sets of numbers 1 to k
python-just-count-complete-sets-of-numbe-xky7
What a wonderful problem! You need to recognize that for each \u201Cposition\u201D in a sequence of x rolls to be produced, you are going to need to have found
jamzz8
NORMAL
2022-07-23T16:05:46.848817+00:00
2022-07-23T16:05:46.848845+00:00
36
false
What a wonderful problem! You need to recognize that for each \u201Cposition\u201D in a sequence of x rolls to be produced, you are going to need to have found at least one each of the numbers from 1 to k (in any order). So, basically, all you have to do is create a set s, and iterate through the items in rolls, keepin...
1
0
[]
1
shortest-impossible-sequence-of-rolls
Easiest Solution Possible + Explanation
easiest-solution-possible-explanation-by-jr8s
Explantion:\n\nJust go and insert all unique elements in unordered set (Bcoz order is not matter here), After that when set size == k means we can create for on
amanchowdhury046
NORMAL
2022-07-23T16:04:09.195050+00:00
2022-07-23T16:04:09.195095+00:00
48
false
Explantion:\n\nJust go and insert all unique elements in unordered set (Bcoz order is not matter here), After that when set size == k means we can create for one more len i.e., len + 1.\n \nEg:\n [4,2,1,2,3,3,2,4,1]\n i=0, set{4};\ni=1, set{4,2};\ni=2, set{4,2,1};\ni=3, set{4,2,1};\ni=5, set{4,2,1,3}; That\'s mea...
1
0
[]
0
shortest-impossible-sequence-of-rolls
With explanation | C++ | Easy to understand |
with-explanation-c-easy-to-understand-by-il13
Explanation:-\n1. You have to calculate number of subarrays that contains all numbers from 1 to k. \n2. Eg;- Let k=5; then for len=1 you need all number from 1
aman282571
NORMAL
2022-07-23T16:02:02.346308+00:00
2022-07-23T16:02:02.346339+00:00
33
false
**Explanation:-**\n1. You have to calculate number of subarrays that contains all numbers from 1 to k. \n2. Eg;- Let k=5; then for len=1 you need all number from 1 to 5. Now for len=2:- 1...5 numbers need 1...5 numbers again to form all the possible 2 length sequences.\n3. You can think that first subarray 1...5 ca...
1
0
[]
0
shortest-impossible-sequence-of-rolls
O(N) simple C++ approach, observation based
on-simple-c-approach-observation-based-b-mgdp
\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n set<int>s;\n int n = rolls.size(), ans = 1;\n for(int
aryan1995
NORMAL
2022-07-23T16:02:00.147952+00:00
2022-07-23T16:02:16.480137+00:00
38
false
```\nclass Solution {\npublic:\n int shortestSequence(vector<int>& rolls, int k) {\n set<int>s;\n int n = rolls.size(), ans = 1;\n for(int i = n-1; i>=0; i--){\n s.insert(rolls[i]);\n if(s.size() == k){\n //sequence of length ans is possible(as we have got all th...
1
0
['C', 'Ordered Set']
0
shortest-impossible-sequence-of-rolls
Python | Greedy | Set | O(n)
python-greedy-set-on-by-aryonbe-dpcr
My code is originated from the following idea.\nMain Idea: to make all the sequences of rolls of length q, the given array rolls should be split into q segments
aryonbe
NORMAL
2022-07-23T16:01:04.934413+00:00
2022-07-23T16:26:04.395942+00:00
122
false
My code is originated from the following idea.\nMain Idea: to make all the sequences of rolls of length q, the given array rolls should be split into q segments where each segment contains all the numbers from 1 to k.\n```\nclass Solution:\n def shortestSequence(self, rolls: List[int], k: int) -> int:\n V = s...
1
0
['Greedy', 'Python']
0
shortest-impossible-sequence-of-rolls
[C++] unordered_set, one pass, O(n)
c-unordered_set-one-pass-on-by-kevin1010-67tu
Explanation\nIf every sequence of rolls of length len can be taken from rolls, then the rolls can be divided to len group and every groups must contains every n
kevin1010607
NORMAL
2022-07-23T16:00:36.767779+00:00
2022-07-23T16:00:36.767815+00:00
147
false
**Explanation**\nIf every sequence of rolls of length `len` can be taken from rolls, then the rolls can be divided to `len` group and every groups must contains every number from `1` to `k`.\nSo we just traverse the rolls and use a set to store number, when meet every number from `1` to `k`, clear the set and `res++`.\...
1
0
[]
0
shortest-impossible-sequence-of-rolls
Simple Greedy Solution C++ ✅✅
simple-greedy-solution-c-by-jayesh_06-1zsx
Code
Jayesh_06
NORMAL
2025-03-27T11:43:18.001151+00:00
2025-03-27T11:43:18.001151+00:00
2
false
# Code ```cpp [] class Solution { public: int shortestSequence(vector<int>& rolls, int k) { int n=rolls.size(),curr_k=1,c=0; vector<int> v(k+1); for(int i=0;i<n;i++){ if(v[rolls[i]]!=curr_k){ v[rolls[i]]=curr_k; c++; } if(...
0
0
['Array', 'Hash Table', 'Greedy', 'C++']
0
shortest-impossible-sequence-of-rolls
JAVA easy
java-easy-by-navalbihani15-8e1d
IntuitionApproachComplexity Time complexity: Space complexity: Code
navalbihani15
NORMAL
2025-03-27T10:23:57.607170+00:00
2025-03-27T10:23:57.607170+00:00
1
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 `...
0
0
['Java']
0
shortest-impossible-sequence-of-rolls
2350. Shortest Impossible Sequence of Rolls
2350-shortest-impossible-sequence-of-rol-u7di
IntuitionApproachComplexity Time complexity: Space complexity: Code
G8xd0QPqTy
NORMAL
2025-01-18T10:37:28.319678+00:00
2025-01-18T10:37:28.319678+00:00
6
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 `...
0
0
['C++']
0
shortest-impossible-sequence-of-rolls
Easy simple solution | c++ | small code
easy-simple-solution-c-small-code-by-vin-rz1g
IntuitionThe problem requires finding the shortest impossible sequence length that can be formed using the rolls. The key observation is that a sequence of leng
vinayjaiswal9919
NORMAL
2025-01-04T14:50:07.103886+00:00
2025-01-04T14:50:07.103886+00:00
10
false
# Intuition The problem requires finding the shortest impossible sequence length that can be formed using the rolls. The key observation is that a sequence of length n requires at least k^n unique combinations of rolls. By tracking how many unique numbers from 1 to k have been seen, we can determine when it is no longe...
0
0
['C++']
1
shortest-impossible-sequence-of-rolls
Easy simple solution | c++ | small code
easy-simple-solution-c-small-code-by-vin-llyy
IntuitionThe problem requires finding the shortest impossible sequence length that can be formed using the rolls. The key observation is that a sequence of leng
vinayjaiswal9919
NORMAL
2025-01-04T14:50:04.649396+00:00
2025-01-04T14:50:04.649396+00:00
2
false
# Intuition The problem requires finding the shortest impossible sequence length that can be formed using the rolls. The key observation is that a sequence of length n requires at least k^n unique combinations of rolls. By tracking how many unique numbers from 1 to k have been seen, we can determine when it is no longe...
0
0
['C++']
1
shortest-impossible-sequence-of-rolls
Java Python3 C++ || 2ms 11ms 0ms || Bitmask or array to find 1..k groups
java-python3-c-2ms-11ms-0ms-bitmask-or-a-1ddd
Note: The leetcode problem description did not give its definition of a "subsequence". For this problem, a "subsequence" is defined as deleting any number of
dudeandcat
NORMAL
2024-12-21T06:56:50.997246+00:00
2024-12-21T07:45:58.017319+00:00
6
false
*Note: The leetcode problem description did not give its definition of a "subsequence". For this problem, a "subsequence" is defined as deleting any number of values from any indexes in `rolls[]`, but the remaining `rolls[]` values must keep the same relative order.*\n\nThe code below is available in both Java and Py...
0
0
['C', 'Java', 'Python3']
0