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
minimum-white-tiles-after-covering-with-carpets
Python top-down DP | Almost one-liner
python-top-down-dp-almost-one-liner-by-t-7myh
\nclass Solution:\n def minimumWhiteTiles(self, nums: str, numCarpets: int, carpetLen: int) -> int:\n @cache\n def dfs(i, rem):\n re
TiruT
NORMAL
2022-09-23T11:40:13.527695+00:00
2022-09-23T11:40:13.527739+00:00
49
false
```\nclass Solution:\n def minimumWhiteTiles(self, nums: str, numCarpets: int, carpetLen: int) -> int:\n @cache\n def dfs(i, rem):\n return 0 if i >= len(nums) else min((1 if nums[i]==\'1\' else 0) + dfs(i+1, rem), dfs(i+carpetLen, rem-1) if rem and nums[i]==\'1\' else float(\'inf\'))\n ...
1
0
['Dynamic Programming', 'Memoization', 'Python']
0
minimum-white-tiles-after-covering-with-carpets
C++ || PrefixSum || DP memoized
c-prefixsum-dp-memoized-by-binaykr-2bl1
\nclass Solution {\n int solve(string &s, int nc, int &lc, vector<int> &pref, int i, vector<vector<int>> &dp)\n {\n if(i<0) return 0;\n if(n
binayKr
NORMAL
2022-06-25T04:58:00.294439+00:00
2022-07-16T12:51:26.102244+00:00
95
false
```\nclass Solution {\n int solve(string &s, int nc, int &lc, vector<int> &pref, int i, vector<vector<int>> &dp)\n {\n if(i<0) return 0;\n if(nc==0) return pref[i];\n if(dp[i][nc]!=-1) return dp[i][nc];\n \n int take = solve(s,nc-1,lc,pref, i-lc, dp);\n int not_take = (s[...
1
2
['Dynamic Programming', 'Recursion', 'Memoization', 'Prefix Sum']
0
minimum-white-tiles-after-covering-with-carpets
C++ | DP | MEMOIZATION
c-dp-memoization-by-jatinbansal1179-bug5
\nclass Solution {\npublic:\n \n int helper(string &s, int num, int len, int i, vector<vector<int>>&dp){\n if(i>=s.length()){\n return 0
jatinbansal1179
NORMAL
2022-06-24T11:07:35.033862+00:00
2022-06-24T11:07:35.033906+00:00
117
false
```\nclass Solution {\npublic:\n \n int helper(string &s, int num, int len, int i, vector<vector<int>>&dp){\n if(i>=s.length()){\n return 0;\n }\n if(num==0){\n int count = 0;\n for(int j = i; j<=s.length()-1;j++){\n if(s[j]==\'1\'){\n co...
1
0
['Memoization', 'C']
0
minimum-white-tiles-after-covering-with-carpets
Python. 2 Liner. using Lambda function and LRU cache///
python-2-liner-using-lambda-function-and-hvl6
\nclass Solution:\n def minimumWhiteTiles(self, x: str, n: int, cl: int) -> int:\n f=lru_cache(None)(lambda i,n: 0 if i>=len(x) else min((1 if x[i]==\
nag007
NORMAL
2022-06-15T06:15:37.091527+00:00
2022-06-15T06:15:37.091579+00:00
57
false
```\nclass Solution:\n def minimumWhiteTiles(self, x: str, n: int, cl: int) -> int:\n f=lru_cache(None)(lambda i,n: 0 if i>=len(x) else min((1 if x[i]==\'1\' else 0)+f(i+1,n),(inf if n==0 else f(i+cl,n-1))))\n return f(0,n)\n```
1
0
[]
0
minimum-white-tiles-after-covering-with-carpets
C++ | DP | Bottom Up Dp | Similar to Knapsack
c-dp-bottom-up-dp-similar-to-knapsack-by-ch9m
Please upvote\n\nclass Solution {\npublic:\n int minimumWhiteTiles(string floor, int numCarpets, int len) {\n int n=floor.size();\n int x=numCa
GeekyBits
NORMAL
2022-06-05T16:25:31.810771+00:00
2022-07-08T17:22:30.056450+00:00
124
false
Please upvote\n```\nclass Solution {\npublic:\n int minimumWhiteTiles(string floor, int numCarpets, int len) {\n int n=floor.size();\n int x=numCarpets;\n floor=\'#\'+floor;//so that ith row of dp matches with the ith character\n vector<vector<int>> dp(n+1,vector<int>(x+1,0));\n dp...
1
0
[]
0
minimum-white-tiles-after-covering-with-carpets
Java DP Solution
java-dp-solution-by-sycmtic-8knv
\nclass Solution {\n public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) {\n int n = floor.length();\n int[][] dp = new i
sycmtic
NORMAL
2022-05-19T04:42:23.856979+00:00
2022-05-19T04:42:23.857005+00:00
132
false
```\nclass Solution {\n public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) {\n int n = floor.length();\n int[][] dp = new int[n + 1][numCarpets + 1];\n for (int i = 1; i <= n; i++) {\n for (int j = 0; j <= numCarpets; j++) {\n if (floor.charAt(i -...
1
0
['Dynamic Programming', 'Java']
0
minimum-white-tiles-after-covering-with-carpets
Scala
scala-by-fairgrieve-m476
\nimport scala.math.min\nimport scala.util.chaining._\n\nobject Solution {\n private val Black = \'0\'\n\n def minimumWhiteTiles(floor: String, numCarpets: In
fairgrieve
NORMAL
2022-03-25T00:16:11.091644+00:00
2022-03-25T00:21:55.757888+00:00
18
false
```\nimport scala.math.min\nimport scala.util.chaining._\n\nobject Solution {\n private val Black = \'0\'\n\n def minimumWhiteTiles(floor: String, numCarpets: Int, carpetLen: Int): Int = floor\n .indices\n .zip(floor.map(_ - Black).scanRight(0)(_ + _))\n .toMap\n .withDefaultValue(0)\n .pipe { (1 to nu...
1
0
[]
0
minimum-white-tiles-after-covering-with-carpets
Java || Simple || Memiozation
java-simple-memiozation-by-lagahuahubro-6icj
```\nclass Solution {\n int[] suff;\n Integer[][] dp;\n public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) { \n if (ca
lagaHuaHuBro
NORMAL
2022-03-24T14:55:00.883915+00:00
2022-03-24T14:55:00.883952+00:00
63
false
```\nclass Solution {\n int[] suff;\n Integer[][] dp;\n public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) { \n if (carpetLen == floor.length()) {\n return 0;\n }\n dp = new Integer[floor.length()][numCarpets + 1];\n // suff[i] = number of white...
1
0
[]
0
minimum-white-tiles-after-covering-with-carpets
Why my bottom-up code is giving TLE?
why-my-bottom-up-code-is-giving-tle-by-k-w441
\nclass Solution {\npublic:\n // int memo(int i, int j, vector<int>& pref, int cl,\n // vector<vector<int>>& dp)\n // {\n // if(i >= pr
kenkaneki124
NORMAL
2022-03-24T11:28:00.423753+00:00
2022-03-24T11:28:23.948191+00:00
92
false
```\nclass Solution {\npublic:\n // int memo(int i, int j, vector<int>& pref, int cl,\n // vector<vector<int>>& dp)\n // {\n // if(i >= pref.size() || j <= 0)\n // return 0;\n // if(dp[i][j] != -1)\n // return dp[i][j];\n // else\n // {\n // ...
1
0
['Dynamic Programming', 'Memoization', 'C']
0
minimum-white-tiles-after-covering-with-carpets
Java Simple Top Down DP with explanation
java-simple-top-down-dp-with-explanation-rky2
Basically we consider each suffix from floor[0...I] using J carpets. There are 2 transition options to consider and minimize over for this building upon "smalle
theted
NORMAL
2022-03-21T14:47:12.810235+00:00
2022-03-21T14:47:56.450381+00:00
76
false
Basically we consider each suffix from ```floor[0...I]``` using ```J``` carpets. There are 2 transition options to consider and minimize over for this building upon "smaller"* subproblems.\n\nCase 1: We use a carpet that ends at ```I```th position. So this means we simply need ```subproblem(I-carpetLen, J-1)``` because...
1
0
['Dynamic Programming', 'Java']
1
minimum-white-tiles-after-covering-with-carpets
Java Solution | Top-Down DP | 2 approaches
java-solution-top-down-dp-2-approaches-b-pney
Explanation :\n\nHere, I want to showcase 2 approaches for solving the problem using memoization :\n\t\t1. counting the minimum number of exposed white tiles us
arcpri
NORMAL
2022-03-20T08:33:16.556988+00:00
2022-03-20T08:41:56.786657+00:00
86
false
**Explanation :**\n\nHere, I want to showcase 2 approaches for solving the problem using memoization :\n\t\t1. counting the minimum number of exposed white tiles using `suffix-sum` and\n\t\t2. counting the maximum number of white tiles covered by the given carpets and subtracting this from the total number of white til...
1
0
['Dynamic Programming', 'Memoization', 'Prefix Sum', 'Java']
1
minimum-white-tiles-after-covering-with-carpets
Java | DP | Memoization
java-dp-memoization-by-sohailabbas1000-yk4o
Do Binary Search and store indices of whites tiles.\n2. We can use DP here now where:\ndp(floorLength, numCarpets) = max(dp(floorLength - carpetLen, numCarpets
sohailabbas1000
NORMAL
2022-03-20T08:04:30.855153+00:00
2022-03-20T08:04:30.855184+00:00
54
false
1. Do Binary Search and store indices of whites tiles.\n2. We can use DP here now where:\ndp(floorLength, numCarpets) = max(dp(floorLength - carpetLen, numCarpets - 1) + numOfWhiteTilesInRange(floorLength - carpetLen, floorLength), dp(floorLength - carpetLen, numCarpets - 1)) -> number of white tiles covered from index...
1
1
['Dynamic Programming', 'Memoization', 'Java']
0
minimum-white-tiles-after-covering-with-carpets
JAVA Simple Solution with Explaination
java-simple-solution-with-explaination-b-fii3
I was having the problem to think but got intuition of DP by seeing constraints. But Now how to implement DP what will be the variables to play . Basically thin
anmolbisht10
NORMAL
2022-03-19T23:25:57.061831+00:00
2022-03-19T23:25:57.061866+00:00
75
false
I was having the problem to think but got intuition of DP by seeing constraints. But Now how to implement DP what will be the variables to play . Basically think on which variables you are dependent;\nYes You have to travel the complete the floor string so this variable is changing and second the number of carpet is ch...
1
0
['Dynamic Programming', 'Java']
0
minimum-white-tiles-after-covering-with-carpets
DP + edge case optimization with explanations
dp-edge-case-optimization-with-explanati-jkdy
Two edge cases can be handled explicitly before running DP:\n(1) if numCarpets * carpetLen >= n, i.e. the totally length of carpets altogether is longer than th
xil899
NORMAL
2022-03-19T20:59:35.455654+00:00
2022-03-19T20:59:35.455683+00:00
98
false
Two edge cases can be handled explicitly before running DP:\n(1) `if numCarpets * carpetLen >= n`, i.e. the totally length of carpets altogether is longer than the length of `floor`, return 0 immediately;\n(2) `if carpetLen == 1`, then the problem becomes trivial and we can cover the carpets "greedily". Adding this edg...
1
0
['Dynamic Programming', 'Python', 'Python3']
0
minimum-white-tiles-after-covering-with-carpets
C++ || EASY TO UNDERSTAND || Memoization Code
c-easy-to-understand-memoization-code-by-wu5n
\nclass Solution {\npublic:\n int dp[1002][1002];\n int solve(string &floor,int i,int n,int l,vector<int> &prefix)\n {\n if(i>=floor.size()||n==
aarindey
NORMAL
2022-03-19T19:59:33.599700+00:00
2022-03-19T19:59:33.599736+00:00
26
false
```\nclass Solution {\npublic:\n int dp[1002][1002];\n int solve(string &floor,int i,int n,int l,vector<int> &prefix)\n {\n if(i>=floor.size()||n==0)\n return 0;\n if(dp[i][n]!=-1)\n return dp[i][n];\n if(floor[i]==\'0\')\n return dp[i][n]=solve(floor,i+1,n,l,prefix);\...
1
0
[]
0
minimum-white-tiles-after-covering-with-carpets
C++ | DP | Recursion + Memorization | Easy to Understand
c-dp-recursion-memorization-easy-to-unde-wvus
c++\nclass Solution {\npublic:\n int carpetLen, fLen;\n vector<int> sum;\n vector<vector<int>> dp;\n int solve(int pos, int numCar, string& floor){\
badhansen
NORMAL
2022-03-19T19:45:57.149158+00:00
2022-03-19T19:46:12.781281+00:00
60
false
```c++\nclass Solution {\npublic:\n int carpetLen, fLen;\n vector<int> sum;\n vector<vector<int>> dp;\n int solve(int pos, int numCar, string& floor){\n if(pos >= fLen){\n return 0;\n }\n \n if(numCar == 0){\n return 0;\n }\n \n int &ret...
1
0
['Dynamic Programming', 'Memoization']
0
minimum-white-tiles-after-covering-with-carpets
✅[Java] || Using dynamic programming || Simple Solution
java-using-dynamic-programming-simple-so-x7zl
First, if numCarpets * carpetLen > floor.size(), the answer is always 0 because the entire floor can be covered.\nOtherwise,This problem can be solved by using
shojin_pro
NORMAL
2022-03-19T17:26:38.647344+00:00
2022-03-20T06:00:34.800927+00:00
41
false
First, if numCarpets * carpetLen > floor.size(), the answer is always 0 because the entire floor can be covered.\nOtherwise,This problem can be solved by using dynamic programming.\nThe variables in the DP are\n1. length of confirmed Floor (starting from the left end at 0)\n2. number of carpets used\n\nThe spatial comp...
1
0
[]
0
minimum-white-tiles-after-covering-with-carpets
C++ DP house robber
c-dp-house-robber-by-nanshan0719-lkv5
This problem can be converted to house robber then solved by dynamic programming.\nWhen the total length of carpet is equal to or exceed the length of the floor
nanshan0719
NORMAL
2022-03-19T17:18:21.911926+00:00
2022-03-20T02:27:47.239637+00:00
89
false
This problem can be converted to [house robber](https://leetcode.com/problems/house-robber/) then solved by dynamic programming.\nWhen the total length of carpet is equal to or exceed the length of the floor, there should be no white left. When it\'s not, we should always looking for non-overlapping solution as at leas...
1
0
['Dynamic Programming', 'C']
0
minimum-white-tiles-after-covering-with-carpets
[c++] | DP Solution | Memoization | (100% FAST) | EASY TO UNDERSTAND
c-dp-solution-memoization-100-fast-easy-7a6br
\nclass Solution {\npublic:\n int solve(vector<int> &hash, int &num, int &len, int i, int j, vector<vector<int>> &dp){\n int n = hash.size();\n
narayanbansal35
NORMAL
2022-03-19T17:08:07.382306+00:00
2022-03-21T09:56:59.761543+00:00
77
false
```\nclass Solution {\npublic:\n int solve(vector<int> &hash, int &num, int &len, int i, int j, vector<vector<int>> &dp){\n int n = hash.size();\n if (j >= num or i >= n) return 0;\n if (dp[i][j] != -1) return dp[i][j];\n// Dont want to put the carpet on the ith place\n int not_take ...
1
0
['Dynamic Programming', 'Memoization']
0
minimum-white-tiles-after-covering-with-carpets
C++ Solution | Memo + recursive + prefix array
c-solution-memo-recursive-prefix-array-b-e0nz
So , Here i changed the question instead of finding the minimum no of white tiles after placing k tiles , I am trying to find the maximum white tiles i can cove
X30N_73
NORMAL
2022-03-19T16:54:19.113327+00:00
2022-03-19T16:54:19.113365+00:00
69
false
So , Here i changed the question instead of finding the minimum no of white tiles after placing k tiles , I am trying to find the maximum white tiles i can cover with the k tiles and return the answer after subtracting with the intital no of white tiles present in the string.\n\n```\nclass Solution {\npublic:\n i...
1
0
['Dynamic Programming', 'Recursion']
0
minimum-white-tiles-after-covering-with-carpets
python3 DP O(N*numCarpets) solution got a TLE. Is this intended?
python3-dp-onnumcarpets-solution-got-a-t-uoav
My solution is given as\n\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n dp = dict() # i, num_c
shovsj
NORMAL
2022-03-19T16:33:00.103502+00:00
2022-03-19T16:33:00.103548+00:00
38
false
My solution is given as\n```\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n dp = dict() # i, num_carpets remaining -> num white\n n = len(floor)\n for i in range(n+1)[::-1]:\n for j in range(numCarpets+1):\n if i ==...
1
0
[]
2
minimum-white-tiles-after-covering-with-carpets
dp | intuition with explaination
dp-intuition-with-explaination-by-keepmo-6b03
Intuition\n\n\nlets suppose are at ith index.\n\nsuppose we are at index i and with j carpets\ndp[i][j] denotes minimum number of uncovered white cells from 0 t
KeepMotivated
NORMAL
2022-03-19T16:09:33.008149+00:00
2022-03-19T16:09:33.008180+00:00
78
false
**Intuition**\n\n\nlets suppose are at ith index.\n\nsuppose we are at index i and with j carpets\ndp[i][j] denotes minimum number of uncovered white cells from 0 to i with j \ncarpets.\n\n1. if number of carpets = 0 dp[i][j] = number of carpets from 0 to i.\n\n\nsuppose we are at index i and with j carpets\n1. we dont...
1
0
['Dynamic Programming']
0
minimum-white-tiles-after-covering-with-carpets
** Python - DP | Memoization solution **
python-dp-memoization-solution-by-arjuho-4olr
\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n if numCarpets*carpetLen >= len(floor):\n
arjuhooda
NORMAL
2022-03-19T16:05:23.885005+00:00
2022-03-19T16:05:37.303184+00:00
72
false
```\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n if numCarpets*carpetLen >= len(floor):\n return 0\n l = list(map(int,list(floor)))\n dp = [[-1]*(numCarpets+1) for j in range(len(l))]\n \n def rec(i,n):\n ...
1
0
['Memoization', 'Python']
0
minimum-white-tiles-after-covering-with-carpets
DP | Memorization | Easy to Understand solution | C++ | O(n^2) time and O(n^2) space |
dp-memorization-easy-to-understand-solut-8zlg
We can solve this problem by using standard concepts of solving a 2-d DP problem.\nFor each tile, we have two options --\ni) We place a the carpet starting from
sa01042001
NORMAL
2022-03-19T16:04:22.948737+00:00
2022-03-19T16:04:22.948765+00:00
71
false
We can solve this problem by using standard concepts of solving a 2-d DP problem.\nFor each tile, we have two options --\ni) We place a the carpet starting from the current tile\nii) We do not place a carpet\n\nFurther, here is an observations to be made\n-- Placing carpet starting from a black tile is not feasible. SO...
1
0
['Dynamic Programming', 'Memoization', 'C']
0
minimum-white-tiles-after-covering-with-carpets
[Python3] DP solution in O(MN) time and O(N) space
python3-dp-solution-in-omn-time-and-on-s-xg31
dp solution:\n dp[i][j] represents for the max number of covered white tiles within floor[:j + 1] using i carpets\n dp[i][j] = max(max(dp[i][k] for k in range(j
huayu_ivy
NORMAL
2022-03-19T16:02:44.600122+00:00
2022-03-19T16:07:11.242070+00:00
87
false
# dp solution:\n* `dp[i][j]` represents for the max number of covered white tiles within `floor[:j + 1]` using `i` carpets\n* `dp[i][j] = max(max(dp[i][k] for k in range(j)), white count in floor[j - carpetLen : j + 1] + dp[i - 1][j - carpetLen])`\n```\ndef minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen...
1
0
['Dynamic Programming', 'Python']
0
minimum-white-tiles-after-covering-with-carpets
[Python3]2D DP solution explained
python32d-dp-solution-explained-by-prasa-tkk1
\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n \n """\n dp(pos, numC) -> returns
prasanna648
NORMAL
2022-03-19T16:01:37.032874+00:00
2022-03-19T16:01:37.032906+00:00
112
false
```\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n \n """\n dp(pos, numC) -> returns min number of white tiles seen from pos to the end of the floor\n if we have numC number of carpets left\n \n if numC ...
1
0
[]
0
minimum-white-tiles-after-covering-with-carpets
C++ | with comments | DP
c-with-comments-dp-by-aman282571-fd1r
dp[idx][rem] wil store maximum tiles we can cover from idx to last index if we are at index idx with rem amount of carpet\n\n\nclass Solution {\npublic:\n v
aman282571
NORMAL
2022-03-19T16:00:53.718676+00:00
2022-03-19T16:01:59.274387+00:00
111
false
```dp[idx][rem]``` wil store maximum tiles we can cover from ```idx to last index``` if we are at index ```idx``` with ```rem``` amount of carpet\n\n```\nclass Solution {\npublic:\n vector<int>tile;\n vector<vector<int>>dp;\n int minimumWhiteTiles(string f, int num, int len) {\n int sz=f.size(),totalWH...
1
0
['C']
0
minimum-white-tiles-after-covering-with-carpets
dp and prefix sum
dp-and-prefix-sum-by-johnchen-68r4
IntuitionApproachComplexity Time complexity: Space complexity: Code
johnchen
NORMAL
2025-02-21T16:27:27.598971+00:00
2025-02-21T16:27:27.598971+00:00
5
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
minimum-white-tiles-after-covering-with-carpets
2209. Minimum White Tiles After Covering With Carpets
2209-minimum-white-tiles-after-covering-pdhep
IntuitionApproachComplexity Time complexity: Space complexity: Code
G8xd0QPqTy
NORMAL
2025-01-18T06:41:23.027166+00:00
2025-01-18T06:41:23.027166+00:00
7
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
['Python3']
0
minimum-white-tiles-after-covering-with-carpets
Python Hard
python-hard-by-lucasschnee-zitq
null
lucasschnee
NORMAL
2025-01-15T01:37:08.840227+00:00
2025-01-15T01:37:08.840227+00:00
5
false
```python3 [] class Solution: def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int: N = len(floor) @cache def calc(index, k): if index >= N: return 0 best = calc(index + 1, k) + int(floor[index]) if k > 0: ...
0
0
['Python3']
0
minimum-white-tiles-after-covering-with-carpets
Java | Dynamic Programming | Prefix Sum | Comments Explanation
java-dynamic-programming-prefix-sum-comm-vlks
\nclass Solution {\n public Integer dp[][];\n public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) {\n int n = floor.length();
Sampath1804
NORMAL
2024-12-23T15:25:16.538741+00:00
2024-12-23T15:25:16.538778+00:00
2
false
```\nclass Solution {\n public Integer dp[][];\n public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) {\n int n = floor.length();\n // if floor length is less than or equal to avaliable tiles return 0\n if(n <= numCarpets*carpetLen) return 0;\n \n //dp array...
0
0
['Dynamic Programming', 'Memoization', 'Prefix Sum', 'Java']
0
minimum-white-tiles-after-covering-with-carpets
DP, O(n^2) TC
dp-on2-tc-by-filinovsky-1sq0
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
Filinovsky
NORMAL
2024-12-05T13:13:11.168961+00:00
2024-12-05T13:13:11.168986+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
['Python3']
0
minimum-white-tiles-after-covering-with-carpets
💥 Beats 100% on runtime [EXPLAINED]
beats-100-on-runtime-explained-by-r9n-ukw7
Intuition\nMinimize the number of white tiles visible after covering them with carpets. Carpets can overlap, and each carpet can cover a fixed number of consecu
r9n
NORMAL
2024-11-10T10:10:50.553170+00:00
2024-11-10T10:10:50.553197+00:00
0
false
# Intuition\nMinimize the number of white tiles visible after covering them with carpets. Carpets can overlap, and each carpet can cover a fixed number of consecutive tiles. The problem can be tackled using dynamic programming, where we explore whether it\'s better to cover certain tiles or leave them uncovered.\n\n# A...
0
0
['String', 'Dynamic Programming', 'Prefix Sum', 'C#']
0
minimum-white-tiles-after-covering-with-carpets
Python (Simple DP)
python-simple-dp-by-rnotappl-v04u
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
rnotappl
NORMAL
2024-11-01T16:55:15.136288+00:00
2024-11-01T16:55:15.136340+00:00
9
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
minimum-white-tiles-after-covering-with-carpets
lee215's PYTHON solution with comments
lee215s-python-solution-with-comments-by-pq16
Copying lee215\'s solution\n# https://leetcode.com/u/lee215/\n\n# Code\npython3 []\n\n# Copying lee215\'s solution\n# https://leetcode.com/u/lee215/\n\nimport f
greg_savage
NORMAL
2024-10-30T04:04:07.814432+00:00
2024-10-30T04:04:07.814470+00:00
4
false
# Copying lee215\'s solution\n# https://leetcode.com/u/lee215/\n\n# Code\n```python3 []\n\n# Copying lee215\'s solution\n# https://leetcode.com/u/lee215/\n\nimport functools\n\nclass Solution:\n\n def minimumWhiteTiles(self, tiles, remaining_carpets, carpet_length):\n\n @lru_cache(None)\n def _layCarpe...
0
0
['Python3']
0
minimum-white-tiles-after-covering-with-carpets
Python 3: FT 99%, TC O(N*C), SC O(N): 2D DP
python-3-ft-99-tc-onc-sc-on-2d-dp-by-big-cp1n
Intuition\n\nUsually when the problem is on an array and we have a limited number of items, the solution is\n dynamic programming\n with two variables\n one is
biggestchungus
NORMAL
2024-09-28T23:14:36.131321+00:00
2024-09-28T23:14:36.131343+00:00
1
false
# Intuition\n\nUsually when the problem is on an array and we have a limited number of items, the solution is\n* dynamic programming\n* with two variables\n* one is the current index in the array\n* and the other is the number of items we\'ve used\n\nI found the DP relation to be a bit tricky, but after some wrangling,...
0
0
['Python3']
0
minimum-white-tiles-after-covering-with-carpets
Java - Recursive DP
java-recursive-dp-by-shinchan_thakur-noli
Intuition\nhttps://youtu.be/lPQSy4WfMOg\n\n# Complexity\n- Time complexity:\nO(floor.length * numCarpets)\n\n- Space complexity:\nO(floor.length * numCarpets)\n
Shinchan_Thakur
NORMAL
2024-09-12T00:09:28.257064+00:00
2024-09-12T00:09:28.257093+00:00
10
false
# Intuition\nhttps://youtu.be/lPQSy4WfMOg\n\n# Complexity\n- Time complexity:\nO(floor.length * numCarpets)\n\n- Space complexity:\nO(floor.length * numCarpets)\n\n# Code\n```java []\nclass Solution {\n private int[][] dp;\n private int n;\n\n private int minWhiteTiles(int pos, int carpetsLeft, String floor, i...
0
0
['Dynamic Programming', 'Recursion', 'Java']
0
minimum-white-tiles-after-covering-with-carpets
✅DP || python
dp-python-by-darkenigma-y21v
\n# Code\npython3 []\nclass Solution:\n\n def check(self,s,dp,i,j,n,k,l):\n if(i>=n):return 0\n if(dp[i][j]!=-1):return dp[i][j]\n if(s[
darkenigma
NORMAL
2024-09-06T20:48:16.546386+00:00
2024-09-06T20:48:16.546414+00:00
18
false
\n# Code\n```python3 []\nclass Solution:\n\n def check(self,s,dp,i,j,n,k,l):\n if(i>=n):return 0\n if(dp[i][j]!=-1):return dp[i][j]\n if(s[i]==\'0\'):\n dp[i][j]=self.check(s,dp,i+1,j,n,k,l)\n return dp[i][j]\n dp[i][j]=1+self.check(s,dp,i+1,j,n,k,l)\n if(j<k)...
0
0
['String', 'Dynamic Programming', 'Prefix Sum', 'Python3']
0
minimum-white-tiles-after-covering-with-carpets
Python Solution for minimumWhiteTiles
python-solution-for-minimumwhitetiles-by-yjr6
Code\npython []\nclass Solution(object):\n\n def minimumWhiteTiles(self, floor, numCarpets, carpetLen):\n\n mat = [[0 for i in range(0,len(floor))] fo
asrith_dasari
NORMAL
2024-08-27T14:26:30.440767+00:00
2024-08-27T14:26:30.440797+00:00
0
false
# Code\n```python []\nclass Solution(object):\n\n def minimumWhiteTiles(self, floor, numCarpets, carpetLen):\n\n mat = [[0 for i in range(0,len(floor))] for j in range(0,numCarpets+1)]\n\n count = 1\n\n temp_count = 0\n\n for i in range(0,len(floor)):\n\n if floor[i]==\'1\':\n\...
0
0
['Python']
0
minimum-white-tiles-after-covering-with-carpets
Interview Preparation
interview-preparation-by-najnifatima01-oeq6
Let me clarify the question once ...\ntestcase\nconstraints :\n1 <= carpetLen <= floor.length <= 1000\nfloor[i] is either \'0\' or \'1\'.\n1 <= numCarpets <= 10
najnifatima01
NORMAL
2024-08-19T09:40:12.360137+00:00
2024-08-19T09:40:12.360172+00:00
3
false
Let me clarify the question once ...\ntestcase\nconstraints :\n1 <= carpetLen <= floor.length <= 1000\nfloor[i] is either \'0\' or \'1\'.\n1 <= numCarpets <= 1000\nGive me a few minutes to think it through\ncomment - BF, optimal\ncode\n\n\n# Intuition\ndp\n\n# Approach - tabulation\n\n# Complexity\n- Time complexity:\n...
0
0
['C++']
0
minimum-white-tiles-after-covering-with-carpets
Easy DP explanation with intuition | Memo | Recursion | Bottom-up | Top Down
easy-dp-explanation-with-intuition-memo-j8rxc
Intuition\n Describe your first thoughts on how to solve this problem. \nIf it was a continous carpets question, this could probably solved by sliding window wh
SheetalB
NORMAL
2024-08-07T02:51:32.312689+00:00
2024-08-07T02:51:32.312727+00:00
26
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf it was a continous carpets question, this could probably solved by sliding window which were my first thoughts. Later understood that the carpets can be placed anywhere so this becomes including excluding recursion problem.\n\n# Approa...
0
0
['String', 'Dynamic Programming', 'Prefix Sum', 'JavaScript']
0
minimum-white-tiles-after-covering-with-carpets
Python (Simple DP)
python-simple-dp-by-rnotappl-qsiq
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
rnotappl
NORMAL
2024-07-25T17:24:02.176897+00:00
2024-07-25T17:24:02.176929+00:00
2
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
minimum-white-tiles-after-covering-with-carpets
DP || C++
dp-c-by-scraper_nerd-zyax
\n\n# Code\n\nclass Solution {\npublic:\n int dp[1001][1001];\n int nerd(int index,int used,int total,int len,vector<int>&v){\n if(index>=v.size()
Scraper_Nerd
NORMAL
2024-06-16T05:56:40.902412+00:00
2024-06-16T05:56:40.902437+00:00
12
false
\n\n# Code\n```\nclass Solution {\npublic:\n int dp[1001][1001];\n int nerd(int index,int used,int total,int len,vector<int>&v){\n if(index>=v.size() or used==total) return 0;\n if(dp[index][used]!=-1) return dp[index][used];\n int notusing=nerd(index+1,used,total,len,v);\n int usingt=...
0
0
['Dynamic Programming', 'C++']
0
minimum-white-tiles-after-covering-with-carpets
Beats 100!! efficient js solution using dp
beats-100-efficient-js-solution-using-dp-c1p6
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
Jdev740
NORMAL
2024-06-07T04:52:53.202448+00:00
2024-06-07T04:52:53.202482+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
['JavaScript']
0
minimum-white-tiles-after-covering-with-carpets
easy c++ solution using prefix sum and dynamic programming
easy-c-solution-using-prefix-sum-and-dyn-7wau
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
Amanr_nitw
NORMAL
2024-05-24T06:38:32.341577+00:00
2024-05-24T06:38:32.341612+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:\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
minimum-white-tiles-after-covering-with-carpets
Dp with prefix sum
dp-with-prefix-sum-by-maxorgus-n5nm
i, where we are\nj, carpets we have left\n\n# Code\n\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n
MaxOrgus
NORMAL
2024-05-24T02:49:41.197074+00:00
2024-05-24T02:49:41.197103+00:00
9
false
i, where we are\nj, carpets we have left\n\n# Code\n```\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n n = len(floor)\n psum = [0]\n for a in floor:\n if a == \'1\':\n psum.append(psum[-1]+1)\n else:\n ...
0
0
['Dynamic Programming', 'Prefix Sum', 'Python3']
0
minimum-white-tiles-after-covering-with-carpets
Shortest DP
shortest-dp-by-yoongyeom-ieaf
Code\n\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n @cache\n def dp(i, car):\n
YoonGyeom
NORMAL
2024-05-18T08:08:31.411272+00:00
2024-05-18T08:08:31.411319+00:00
5
false
# Code\n```\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n @cache\n def dp(i, car):\n if i >= len(floor): return 0\n if car == 0: return dp(i+1, car)+int(floor[i]==\'1\')\n return min(dp(i+1, car)+int(floor[i]==\'1\...
0
0
['Python3']
0
minimum-white-tiles-after-covering-with-carpets
C# solution beats 100%??
c-solution-beats-100-by-obose-q3cp
Intuition\n Describe your first thoughts on how to solve this problem. \nMy first thought on how to solve this problem is to use dynamic programming (DP) to fin
Obose
NORMAL
2024-05-14T04:22:33.343551+00:00
2024-05-14T04:22:33.343595+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMy first thought on how to solve this problem is to use dynamic programming (DP) to find the minimum number of white tiles that need to be painted black. The problem seems to be a classic example of a DP problem, where we need to make dec...
0
0
['C#']
0
minimum-white-tiles-after-covering-with-carpets
rust 17ms solution with explaination
rust-17ms-solution-with-explaination-by-yvpwu
\n\n# Approach\nTo get the min exposed is to get the max covered;\n\nLet dp[n][i] be the max_covered with n carpets, let m be the length of carpets.\n\ndp[n][i]
sovlynn
NORMAL
2024-04-10T18:41:46.512553+00:00
2024-04-10T18:41:46.512573+00:00
0
false
![image.png](https://assets.leetcode.com/users/images/612f5345-e554-4d44-907d-20222a260dd6_1712773598.1896548.png)\n\n# Approach\nTo get the min exposed is to get the max covered;\n\nLet dp[n][i] be the max_covered with n carpets, let m be the length of carpets.\n\ndp[n][i]=max(\ndp[n-1][i-M]+cover[i-M+1] \\\\\\*I choo...
0
0
['Dynamic Programming', 'Rust']
0
minimum-white-tiles-after-covering-with-carpets
C++ sliding window + dp memo
c-sliding-window-dp-memo-by-user5976fh-v596
\nclass Solution {\npublic:\n // dp memo based on amount of carpets left and current index\n // first perform a sliding window to determine\n // how ma
user5976fh
NORMAL
2024-03-25T21:28:06.887659+00:00
2024-03-25T21:28:06.887690+00:00
1
false
```\nclass Solution {\npublic:\n // dp memo based on amount of carpets left and current index\n // first perform a sliding window to determine\n // how many tiles we cover\n vector<int> tilesCovered;\n int l = 1;\n string s = "";\n vector<vector<int>> dp;\n int minimumWhiteTiles(string str, int ...
0
0
[]
0
minimum-white-tiles-after-covering-with-carpets
Minumum White Tiles
minumum-white-tiles-by-user9233o-01nh
\n# Code\n\npublic class Solution {\n public int MinimumWhiteTiles(string floor, int numCarpets, int carpetLen) {\n int n = floor.Length;\n
user9233O
NORMAL
2024-03-12T10:27:48.477753+00:00
2024-03-12T10:27:48.477791+00:00
3
false
\n# Code\n```\npublic class Solution {\n public int MinimumWhiteTiles(string floor, int numCarpets, int carpetLen) {\n int n = floor.Length;\n int[,] dp = new int[n + 1, numCarpets + 1];\n\n for (int i = 1; i <= n; ++i)\n {\n for (int k = 0; k <= numCarpets; ++k...
0
0
['C#']
0
minimum-white-tiles-after-covering-with-carpets
Efficient JS solution - DP (Beat 100% time)
efficient-js-solution-dp-beat-100-time-b-u9om
\n\nPro tip: Love lil Xi\xE8 \uD83D\uDC9C \u7231\u5C0F\u8C22 \uD83D\uDC9C\n\n# Complexity\n- let n = floor.length, c = numCarpets\n- Time complexity: O(nc)\n- S
CuteTN
NORMAL
2024-01-18T17:29:57.916997+00:00
2024-01-18T17:29:57.917026+00:00
12
false
![image.png](https://assets.leetcode.com/users/images/197c73b5-11df-4d7f-a64a-0922789cc1b7_1705598883.7087042.png)\n\nPro tip: Love lil Xi\xE8 \uD83D\uDC9C \u7231\u5C0F\u8C22 \uD83D\uDC9C\n\n# Complexity\n- let `n = floor.length`, `c = numCarpets`\n- Time complexity: $$O(nc)$$\n- Space complexity: $$O(nc)$$\n\n# Code\n...
0
0
['Dynamic Programming', 'JavaScript']
0
minimum-white-tiles-after-covering-with-carpets
DP
dp-by-hidanie-hzdl
Intuition\n Describe your first thoughts on how to solve this problem. \nCover the tiles carpet by carpet from end to beginning. for each carpet, choose the the
hidanie
NORMAL
2023-12-19T19:26:27.198180+00:00
2023-12-19T19:26:27.198208+00:00
12
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCover the tiles carpet by carpet from end to beginning. for each carpet, choose the the place that the sum of the tiles he and his predecessors cover the most.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Co...
0
0
['Java']
0
minimum-white-tiles-after-covering-with-carpets
Simple Explanation and Solution (Memoization) [Python]
simple-explanation-and-solution-memoizat-say4
Intuition\nBacktracking memoization solution. At every step we either place a carpet or don\'t - we do whatever minimizes the number of exposed white tiles. For
Atjowt
NORMAL
2023-12-18T04:56:38.926026+00:00
2023-12-18T04:56:38.926054+00:00
22
false
# Intuition\nBacktracking memoization solution. At every step we either place a carpet or don\'t - we do whatever minimizes the number of exposed white tiles. For every tile we make a binary choice, which means complexity $O(2^n)$, but with memoization we reduce that to $O(n^2)$.\n\n# Complexity\n- Time complexity: $$\...
0
0
['Dynamic Programming', 'Backtracking', 'Recursion', 'Memoization', 'Python', 'Python3']
0
minimum-white-tiles-after-covering-with-carpets
96% Faster Solution
96-faster-solution-by-priyanshuniranjan-zuad
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
PriyanshuNiranjan
NORMAL
2023-12-15T18:39:06.808666+00:00
2023-12-15T18:39:06.808695+00:00
9
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
['Java']
0
minimum-white-tiles-after-covering-with-carpets
Easy intuitive Solution Using Recursion and Memoization||Tabulation
easy-intuitive-solution-using-recursion-1nmmf
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
code_plus_plus
NORMAL
2023-11-13T20:16:27.703183+00:00
2023-11-13T20:16:27.703201+00:00
20
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
minimum-white-tiles-after-covering-with-carpets
Thoroughly Explained C++ code
thoroughly-explained-c-code-by-monkey_d_-q27g
Intuition\nDon\'t think about the overlapping of the carpets because it will be taken care at the end because it can be folded from the end side as well.\n\n# A
Monkey_D_Luffy_2002
NORMAL
2023-11-08T09:52:57.473594+00:00
2023-11-08T09:53:34.105266+00:00
16
false
# Intuition\nDon\'t think about the overlapping of the carpets because it will be taken care at the end because it can be folded from the end side as well.\n\n# Approach\nWe will use a array to store the prefix sum and the find the maximum amount of white tiles that can be removed and then subtract the tiles from total...
0
0
['Dynamic Programming', 'Memoization', 'Prefix Sum', 'C++']
0
minimum-white-tiles-after-covering-with-carpets
python3 dp beats 93%
python3-dp-beats-93-by-0icy-u3hz
\n\n# Code\n\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n floor = \'0\'+floor\n dp = [
0icy
NORMAL
2023-11-06T17:03:08.346356+00:00
2023-11-06T17:03:25.341904+00:00
10
false
\n\n# Code\n```\nclass Solution:\n def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n floor = \'0\'+floor\n dp = [[inf for x in range(len(floor))] for y in range(numCarpets+1)]\n c = 0\n for i in range(len(floor)):\n if floor[i]==\'1\':\n ...
0
0
['Python3']
0
minimum-white-tiles-after-covering-with-carpets
Dp Super Detailed Explanation and Process
dp-super-detailed-explanation-and-proces-kqvn
\n## Initial thoughts \n\nIt looks like initially, me an others considered a greedy approach to optimize the placement of carpets to cover the most white tiles
srd4
NORMAL
2023-11-01T14:11:33.709504+00:00
2023-11-01T14:11:33.709538+00:00
12
false
\n## Initial thoughts \n\nIt looks like initially, me an others considered a greedy approach to optimize the placement of carpets to cover the most white tiles at each step. With counterexamples It became clear though that the approach didn\'t yield the optimal solution. From the solutions section it seemed was rather ...
0
0
['Dynamic Programming', 'Recursion', 'Python3']
0
minimum-white-tiles-after-covering-with-carpets
Easy intuitive Solution Using Recursion and Memoization
easy-intuitive-solution-using-recursion-gm699
Intuition\nwe will try to put carpet on every white tile where it exists till\nour number of carpets are over.\n\n# Approach\nif we find a white tile we will pu
hazarika857
NORMAL
2023-07-31T22:52:38.368711+00:00
2023-07-31T22:52:38.368736+00:00
35
false
# Intuition\nwe will try to put carpet on every white tile where it exists till\nour number of carpets are over.\n\n# Approach\nif we find a white tile we will put a carpet based on the length of\nthe carpet and look for more white tile and put carpet over them too,\nif the number of carpet is over we cant do anything ...
0
0
['Recursion', 'Memoization', 'C++']
0
minimum-white-tiles-after-covering-with-carpets
Dp solution(c++ solution)
dp-solutionc-solution-by-jishudip_389-uokf
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
jishudip389
NORMAL
2023-07-31T15:08:55.479260+00:00
2023-07-31T15:08:55.479290+00:00
9
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
minimum-white-tiles-after-covering-with-carpets
0/1 Knapsack || Pick Not pick || Easy to read concise code
01-knapsack-pick-not-pick-easy-to-read-c-2v9s
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
Rutuj_P
NORMAL
2023-07-18T17:23:42.776729+00:00
2023-07-18T17:23:42.776762+00:00
18
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Dynamic Programming', 'Memoization', 'C++']
0
minimum-white-tiles-after-covering-with-carpets
DP solution || Recursion + Memoization
dp-solution-recursion-memoization-by-eni-9u5j
\nclass Solution {\npublic:\n int solve(int i,string &s,int k,int len,vector<int> &pre,vector<vector<int>> &dp){\n int n = s.size();\n if(i>=n)
enigma79
NORMAL
2023-07-17T05:56:52.678018+00:00
2023-07-17T05:56:52.678036+00:00
4
false
```\nclass Solution {\npublic:\n int solve(int i,string &s,int k,int len,vector<int> &pre,vector<vector<int>> &dp){\n int n = s.size();\n if(i>=n) return 0;\n \n if(dp[i][k]!=-1) return dp[i][k];\n \n int tk=-1e9,ksum=0;\n ksum=(i+len<=n)?(pre[i+len]-pre[i]):(pre[n]-p...
0
0
['Dynamic Programming', 'Memoization']
0
minimum-white-tiles-after-covering-with-carpets
My Solution
my-solution-by-hope_ma-ahay
\n/**\n * the dynamic programming solution is employed.\n *\n * `dp[carpets][tiles]` stands for the minimum number of while tiles\n * when `carpets` carpets hav
hope_ma
NORMAL
2023-07-14T09:19:22.704667+00:00
2023-07-14T09:19:22.704694+00:00
2
false
```\n/**\n * the dynamic programming solution is employed.\n *\n * `dp[carpets][tiles]` stands for the minimum number of while tiles\n * when `carpets` carpets have been covered in the tile range [0, tiles),\n * 0 inclusive, `tiles` exclusive.\n * where `carpets` is in the range [0, `numCarpets`], both inclusive\n * ...
0
0
[]
0
minimum-white-tiles-after-covering-with-carpets
[C++/Java] Memoization - Commented
cjava-memoization-commented-by-suren-yea-9oi9
Code\nC++ []\nclass Solution {\npublic:\n\n #define WHITE \'1\'\n \n vector<vector<int>> dp;\n int n, c;\n \n int solve(string &floor, int ind
suren-yeager
NORMAL
2023-07-06T19:49:22.563788+00:00
2023-07-06T19:49:22.563808+00:00
16
false
## Code\n```C++ []\nclass Solution {\npublic:\n\n #define WHITE \'1\'\n \n vector<vector<int>> dp;\n int n, c;\n \n int solve(string &floor, int ind, int rem){\n\n // Reached end - No white tiles visible\n if(ind >= n) return 0;\n\n // Checking cache\n if(dp[ind][rem] != -1...
0
0
['Memoization', 'C++', 'Java']
0
minimum-white-tiles-after-covering-with-carpets
C++/Python, dynamic programming solution with explanation
cpython-dynamic-programming-solution-wit-tufo
dp[i][j] is minimum number of visible white tiles in the first i tiles ([0, i]) which are coverd by j carpets.\nIf the tile is black, dp[i][j] = dp[i][j-1] + 1.
shun6096tw
NORMAL
2023-07-06T13:50:05.951868+00:00
2023-07-06T13:50:05.951896+00:00
4
false
```dp[i][j]``` is minimum number of visible white tiles in the first ```i``` tiles ([0, i]) which are coverd by ```j``` carpets.\nIf the tile is black, ```dp[i][j] = dp[i][j-1] + 1```.\nIf the tile is white, we have 2 choices,\none is using a carpet to to cover it, ```dp[i][j] = dp[i-1][j-carpetLen]```.\nAnother is not...
0
0
['Dynamic Programming', 'C', 'Python']
0
minimum-white-tiles-after-covering-with-carpets
Easy to Understand | C++ | Recursive | Memoization | DP
easy-to-understand-c-recursive-memoizati-336j
Intuition\n Describe your first thoughts on how to solve this problem. \nDynamic Programming take and not take simple intuition.\n\n# Approach\n Describe your a
AmitKumarn22
NORMAL
2023-06-29T14:27:22.487127+00:00
2023-06-29T14:27:22.487146+00:00
13
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nDynamic Programming take and not take simple intuition.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSolved using Dynamic Programming approach.\nThere are 3 case , starting from the first tile \n1. Black tile : ...
0
0
['C++']
0
counter
Day2=O(1)>Understanding Closure in easy way and its practical uses!!
day2o1understanding-closure-in-easy-way-pr939
When, Where, What, and How to use closure!!!\nFirst of all closure is not something you create it\'s something that the language has created for itself for appr
Cosmic_Phantom
NORMAL
2023-05-06T02:04:08.894012+00:00
2024-08-23T02:18:00.884791+00:00
113,612
false
# When, Where, What, and How to use closure!!!\nFirst of all closure is not something you create it\'s something that the language has created for itself for appropriate development and we need to crack this code that how the language uses it. \n\n"*To be honest, a good developer\'s greatest fear is discovering that so...
627
1
['JavaScript']
40
counter
✔️Counter( ) 2620✔️Level up🚀your JavaScript skills with these intuitive implementations󠁓🚀
counter-2620level-upyour-javascript-skil-qy21
Intuition\n Describe your first thoughts on how to solve this problem. \n>The problem asks us to implement a function that returns a counter, which initially re
Vikas-Pathak-123
NORMAL
2023-05-06T09:00:32.251319+00:00
2023-05-06T09:07:00.284840+00:00
41,994
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n>The problem asks us to implement a function that returns a counter, which initially returns the input number, and then returns a number that is one more than the previous value on each subsequent call. To solve this problem, we need to d...
510
0
['JavaScript']
37
counter
✅💯🔥Simple Code📌🚀| 🔥✔️Easy to understand🎯 | 🎓🧠Beginner friendly🔥| O(n) Time Complexity💀💯
simple-code-easy-to-understand-beginner-cmuz1
Code\n\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n return function() {\n return n++;\n }\n}
atishayj4in
NORMAL
2024-08-12T21:39:20.400612+00:00
2024-08-12T21:39:20.400651+00:00
8,388
false
# Code\n```\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n return function() {\n return n++;\n }\n}\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```\n![7be995b4-0cf4-4fa3-b48b-8086738ea4b...
60
0
['JavaScript']
7
counter
Day 2 - JavaScript and TypeScript
day-2-javascript-and-typescript-by-racha-58yt
Approach - Postfix Increment Syntax\nJavaScript provides convenient syntax that returns a value and then increments it. This allows us to avoid having to initia
mr_rajeshsingh
NORMAL
2023-05-06T00:22:05.812605+00:00
2023-05-07T04:08:42.046539+00:00
22,532
false
# Approach - Postfix Increment Syntax\nJavaScript provides convenient syntax that returns a value and then increments it. This allows us to avoid having to initially set a variable to n - 1.\n\n# Code\n<iframe src="https://leetcode.com/playground/PgQPK2ds/shared" frameBorder="0" width="700" height="300"></iframe>\n
33
1
['TypeScript', 'JavaScript']
7
counter
Solutions in two different approaches....
solutions-in-two-different-approaches-by-hiq3
Day 2 of JavaScript\n\n## Code 1\njavascript []\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n let count
Aim_High_212
NORMAL
2024-11-10T13:00:30.285630+00:00
2024-11-10T13:00:30.285664+00:00
5,284
false
# Day 2 of JavaScript\n\n## Code 1\n```javascript []\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n let count = n;\n return function() {\n return count++;\n };\n};\n```\n## Code 2\n```javascript []\nvar createCounter = function(n) {\n let count = n...
26
0
['Recursion', 'JavaScript']
4
counter
➡️➡️ Double Arrow Function || One-Line || Explained
double-arrow-function-one-line-explained-hr6z
Approach\nThis problem involves the concept of a closure.\n\nA closure is the combination of a function and a reference to the function\'s outer scope.\n\nIt\'s
richardm2789
NORMAL
2023-04-11T22:14:19.051331+00:00
2024-08-05T21:14:22.807351+00:00
11,540
false
# Approach\nThis problem involves the concept of a closure.\n\nA closure is the combination of a function and a reference to the function\'s outer scope.\n\nIt\'s the ability of an inner function to access its outer scope even after the outer function has finished executing.\n\nIn this problem, the closure is the pairi...
22
0
['JavaScript']
6
counter
Counter : Closure
counter-closure-by-santoshmcode-p9ts
Intuition\nThe code snippet defines a function createCounter that takes an integer n as input and returns another function that increments and returns a counter
santoshmcode
NORMAL
2023-04-12T04:06:55.112421+00:00
2023-04-12T04:06:55.112467+00:00
6,990
false
# Intuition\nThe code snippet defines a function `createCounter` that takes an integer n as input and returns another function that increments and returns a counter variable count every time it is called.\n\n# Approach\nThe inner function returned by `createCounter` uses a `closure` to maintain access to the `count` va...
14
0
['JavaScript']
4
counter
Easy and Straightforward Javascript Solution in O(1) Time And Space Complexity ✔✔.
easy-and-straightforward-javascript-solu-gq7y
Intuition \n Describe your first thoughts on how to solve this problem. \n - n is local to createCounter function.\n - n is global to counter function.\n Since
Boolean_Autocrats
NORMAL
2023-05-06T02:43:37.869869+00:00
2023-05-06T02:45:24.137759+00:00
4,925
false
# Intuition \n<!-- Describe your first thoughts on how to solve this problem. -->\n - n is local to createCounter function.\n - n is global to counter function.\n Since in every call we have to return n and in next call we have to\n return n+1 so what we do is we will first store value of n in temp variable and then ...
10
0
['JavaScript']
3
counter
Easy iterative example for beginners 🧨. Please Up vote 🫰🏻
easy-iterative-example-for-beginners-ple-fuk4
Approach\nThinking in multiple ways and knowing the fundamentals is Great\n\n# Complexity\n- Time complexity:\no(1)\n\n- Space complexity:\no(1)\n\n# Code\n\n//
Aribaskar_j_b
NORMAL
2023-04-15T09:40:20.900504+00:00
2023-04-15T09:40:20.900534+00:00
3,038
false
# Approach\nThinking in multiple ways and knowing the fundamentals is Great\n\n# Complexity\n- Time complexity:\no(1)\n\n- Space complexity:\no(1)\n\n# Code\n```\n// Expanded version and simple\nvar createCounter = function (n) {\n var count=0;\n var temp=0;\n return function () {\n if(count===0){\n ...
7
0
['JavaScript']
1
counter
Detailed explanation.
detailed-explanation-by-rupdeep-jd2g
Explanation:\n\n1. The createCounter function takes an integer n as input and initializes a counter variable to n.\n2. It then returns an anonymous function tha
Rupdeep
NORMAL
2023-04-11T21:53:41.869482+00:00
2023-04-11T21:59:20.660977+00:00
1,050
false
Explanation:\n\n1. The createCounter function takes an integer n as input and initializes a counter variable to n.\n2. It then returns an anonymous function that takes no arguments.\n3. When the returned function is called, it returns the current value of counter and then increments counter by 1 using the post-incremen...
7
0
['JavaScript']
1
counter
1/30 days JAVASCRIPT
130-days-javascript-by-doaaosamak-7uzh
"Hello! Here is a code for a straightforward question. Have a great day, and see you tomorrow."\n\nvar createCounter = function(n) {\n return ()=> n++\n};\n
DoaaOsamaK
NORMAL
2024-03-15T13:03:26.256002+00:00
2024-03-15T13:03:26.256036+00:00
664
false
"Hello! Here is a code for a straightforward question. Have a great day, and see you tomorrow."\n```\nvar createCounter = function(n) {\n return ()=> n++\n};\n```
6
0
['JavaScript']
2
counter
✔💯 DAY 401 | MULTIPLE WAYS | [JAVASCRIPT/TYPESCRIPT] | 100% 0ms | EXPLAINED | Approach 🆙🆙🆙
day-401-multiple-ways-javascripttypescri-5xtb
Please Upvote as it really motivates me \uD83C\uDD99\uD83C\uDD99\uD83C\uDD99\n Describe your approach to solving the problem. \n\n\n\n# Complexity\n- Time compl
ManojKumarPatnaik
NORMAL
2023-05-06T02:59:52.044364+00:00
2023-05-06T03:05:43.808901+00:00
310
false
# Please Upvote as it really motivates me \uD83C\uDD99\uD83C\uDD99\uD83C\uDD99\n<!-- Describe your approach to solving the problem. -->\n![image.png](https://assets.leetcode.com/users/images/1e873636-cdf1-41ef-abbd-caed210b7000_1683342340.5855558.png)\n\n\n# Complexity\n- Time complexity:o(1)\n<!-- Add your time comple...
5
1
['TypeScript', 'JavaScript']
0
counter
Solution
solution-by-antovincent-8ls5
\n\n# Code\n\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n return function() {\n return n++;\n
antovincent
NORMAL
2023-05-06T02:54:05.848545+00:00
2023-05-06T02:54:05.848573+00:00
8,221
false
\n\n# Code\n```\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n return function() {\n return n++;\n };\n};\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```
5
0
['JavaScript']
2
counter
✅| Hello world😎 | Commented
hello-world-commented-by-drontitan-6q8m
This code defines a function called createCounter that takes a number n as input and returns another function. The returned function acts as a counter that star
DronTitan
NORMAL
2023-05-06T02:47:26.830787+00:00
2023-05-06T09:10:30.900724+00:00
825
false
This code defines a function called `createCounter` that takes a number `n` as input and returns another function. The returned function acts as a counter that starts at `n` and increments by 1 each time it is called.\n\nHere is how the code works:\n\n1. The `createCounter` function takes a number `n` as input and init...
5
0
['TypeScript', 'JavaScript']
3
counter
EASY 1 line Javascript Solution - Explained Solution
easy-1-line-javascript-solution-explaine-13yb
Intuition\nThe magic of retaining local variables in "memory" of Javascript Closure should come to mind when seeing such problem where we need to return a funct
atiqueahmedziad
NORMAL
2023-04-20T10:35:29.184630+00:00
2023-04-20T11:33:07.311895+00:00
806
false
# Intuition\nThe magic of retaining local variables in "memory" of Javascript Closure should come to mind when seeing such problem where we need to return a function inside another function and recall something from the memory.\n\n# Approach\nWe pass a value of `n` upon calling the `createCounter` method. The value of ...
5
0
['JavaScript']
0
counter
createCounter
createcounter-by-rinatmambetov-7fhm
# Intuition \n\n\n\n\n\n\n\n\n\n\n\n# Code\n\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function (n) {\n let counter
RinatMambetov
NORMAL
2023-04-16T16:39:33.658518+00:00
2023-04-16T16:39:33.658547+00:00
3,007
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 spa...
5
0
['JavaScript']
2
counter
Single Line Code || ✨✨✨
single-line-code-by-user9102in-k9dh
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
user9102In
NORMAL
2023-04-12T16:56:15.974224+00:00
2023-04-12T16:56:15.974264+00:00
4,234
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)$$ --...
5
0
['JavaScript']
1
counter
Create count variable
create-count-variable-by-dchooyc-pg5x
Edit: Should use let instead of var\nlet: block scope\nvar: function scope\n\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter =
dchooyc
NORMAL
2023-04-11T21:35:54.875700+00:00
2023-04-11T22:09:50.662500+00:00
4,988
false
Edit: Should use ```let``` instead of ```var```\n```let```: block scope\n```var```: function scope\n```\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n let count = n\n return function() {\n count++\n return count - 1\n };\n};\n\n/** \n * const c...
5
0
['JavaScript']
5
counter
JS | "Create Counter Function" | Time Complexity O(1) | 33ms Beats 99.69%
js-create-counter-function-time-complexi-tqz9
---\n\n# Intuition\nThe goal is to implement a counter function that begins at an integer n and increments each time it is called.\n\n# Approach\nDefine a count
user4612MW
NORMAL
2024-08-17T12:51:49.866851+00:00
2024-08-17T12:52:27.544428+00:00
156
false
---\n\n# Intuition\nThe goal is to implement a counter function that begins at an integer n and increments each time it is called.\n\n# Approach\nDefine a counter function that uses a variable to track the current count, starting from a given integer **n**. The function returns another function that increments and retu...
4
0
['JavaScript']
0
counter
[Fully Explained] 1 Line Code with Concept Explanation 🔥| Closures | Arrow Functions | Currying
fully-explained-1-line-code-with-concept-j0qu
Intuition \uD83D\uDCA1\n Describe your first thoughts on how to solve this problem. \nThe goal is simple: start at n and return n + 1 every time the function is
poojagera0_0
NORMAL
2023-05-06T05:13:57.854538+00:00
2023-05-06T05:13:57.854579+00:00
408
false
# Intuition \uD83D\uDCA1\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is simple: start at n and return n + 1 every time the function is called. Easy peasy, right?\n\n# Approach \uD83E\uDD14\n<!-- Describe your approach to solving the problem. -->\nAfter a quick brainstorm, it\'s clear ...
4
0
['JavaScript']
2
counter
JavaScript || Day 2 of 30 Days Challange || ✅✅
javascript-day-2-of-30-days-challange-by-e1uw
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
Shubhamjain287
NORMAL
2023-05-06T04:32:38.996028+00:00
2023-05-06T04:32:38.996063+00:00
1,435
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)$$ --...
4
0
['JavaScript']
1
counter
🔥🔥Easy Simple JavaScript Solution 🔥🔥
easy-simple-javascript-solution-by-motah-l03v
\n\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n let counter=n;\n return function() {\n retur
Motaharozzaman1996
NORMAL
2023-04-18T04:53:40.508021+00:00
2023-04-18T04:53:40.508091+00:00
1,517
false
\n```\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n let counter=n;\n return function() {\n return counter++;\n \n };\n};\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```
4
0
['JavaScript']
0
counter
Single Line Code
single-line-code-by-ankita2905-vb2g
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-24T05:58:10.489522+00:00
2023-10-24T05:58:10.489570+00:00
387
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)$$ --...
3
0
['JavaScript']
1
counter
Solution with explanation
solution-with-explanation-by-tmg_bijay-fdqn
Explanation\nThe first time counter is called, it calls the function(n) and just returns the inner function and do nothing. Now after this, everytime the counte
Tmg_Bijay
NORMAL
2023-09-06T12:39:05.469524+00:00
2023-09-06T12:39:05.469543+00:00
370
false
# Explanation\nThe first time counter is called, it calls the `function(n)` and just returns the inner function and do nothing. Now after this, everytime the counter is called, it calls the inner function that was returned from the first call and remembers the argument `n` passed and increments it in every calls.\n\n# ...
3
0
['JavaScript']
1
counter
Easy to understand || JS
easy-to-understand-js-by-yashwardhan24_s-7ml2
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
yashwardhan24_sharma
NORMAL
2023-05-07T04:51:47.354164+00:00
2023-05-07T04:51:47.354189+00:00
655
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)$$ --...
3
0
['JavaScript']
0
counter
✅Day-2 || 30-Days-JS-Challenge || Best Editorial || Everything Explained || Easy to understand ||🔥
day-2-30-days-js-challenge-best-editoria-ygah
Intuition\n1.The createCounter() function is designed to create a counter function that maintains and increments a specific value (n).\n2.By returning a nested
krishna_6431
NORMAL
2023-05-06T17:59:45.792211+00:00
2023-05-06T17:59:45.792241+00:00
82
false
# Intuition\n1.The $$createCounter()$$ function is designed to create a counter function that maintains and increments a specific value $$(n)$$.\n2.By returning a nested function, the $$createCounter()$$ function encapsulates the value $$n$$ within the returned counter function.\n3.Each time the counter function is inv...
3
0
['JavaScript']
1
counter
Using post increment
using-post-increment-by-harsh_patell21-6e46
\n\n\n var createCounter = function(n) {\n return function() {\n return n++;\n };\n };
harsh_patell21
NORMAL
2023-05-06T12:01:35.801054+00:00
2023-05-06T12:01:35.801090+00:00
38
false
\n\n\n var createCounter = function(n) {\n return function() {\n return n++;\n };\n };
3
0
['JavaScript']
0
counter
Easy one liner O(1) TC javascript solution!! ✔️✔️
easy-one-liner-o1-tc-javascript-solution-uhcd
Intuition\nBasic implementation\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nBasic post increment n every time when you return i
__AKASH_SINGH___
NORMAL
2023-05-06T07:23:41.727838+00:00
2023-05-06T07:23:41.727873+00:00
367
false
# Intuition\nBasic implementation\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nBasic post increment n every time when you return it\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ ...
3
0
['JavaScript']
1
counter
Java Script Solution for Counter Problem
java-script-solution-for-counter-problem-rpkv
Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind the solution is to create a closure that returns a function that i
Aman_Raj_Sinha
NORMAL
2023-05-06T06:38:06.124458+00:00
2023-05-06T06:38:06.124489+00:00
551
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind the solution is to create a closure that returns a function that increments a counter variable n each time it is called.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe approach is to defin...
3
0
['JavaScript']
0
counter
simple counter no logic
simple-counter-no-logic-by-nikunjrathod2-05g0
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
NikunjRathod200
NORMAL
2023-05-06T05:27:24.956951+00:00
2023-05-06T05:27:24.956981+00:00
544
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)$$ --...
3
0
['JavaScript']
0
counter
Two approaches using count (beats 90.25% in memory) | postfix(beats 100% in time) beginner friendly
two-approaches-using-count-beats-9025-in-1e1y
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
abhishekvallecha20
NORMAL
2023-05-06T04:59:57.034274+00:00
2023-05-29T18:57:27.123720+00:00
1,751
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)$$ --...
3
0
['JavaScript']
2
counter
Very simple and easy to understand !!! Just using incrementing
very-simple-and-easy-to-understand-just-qec77
\n# Code\n\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n return function() {\n return n++\n }
AzamatAbduvohidov
NORMAL
2023-05-06T04:02:45.634556+00:00
2023-05-06T04:02:45.634617+00:00
616
false
\n# Code\n```\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n return function() {\n return n++\n };\n};\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```
3
0
['JavaScript']
3
counter
Simplest code ever
simplest-code-ever-by-deepu_7541-d121
Intuition\nWe just have to return the number that will work as a counter.\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe
deepu_7541
NORMAL
2023-04-13T16:12:10.104232+00:00
2023-04-13T16:12:10.104278+00:00
546
false
# Intuition\nWe just have to return the number that will work as a counter.\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 co...
3
0
['JavaScript']
1