Skip to content

Commit 708360f

Browse files
committed
update with prettier
1 parent ae5ad8b commit 708360f

File tree

370 files changed

+13323
-13323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

370 files changed

+13323
-13323
lines changed

dsa/arrays-and-strings/1004.html

+66-66
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
<html>
2-
3-
<head>
4-
<title>one2bla.me</title>
5-
<meta charset="utf-8">
6-
<link href="../../style.css" rel="stylesheet" type="text/css">
7-
</head>
8-
9-
<body>
10-
<div class="txtdiv">
11-
<pre>
12-
< <a href="index.html">Back</a>
13-
14-
15-
16-
17-
<a href="https://leetcode.com/problems/max-consecutive-ones-iii/">1004. Max Consecutive Ones III</a>
18-
19-
Another sliding window problem, however, the size of the subarray we're looking for isn't statically
20-
defined - the window is dynamic and grows and shrinks depending upon how we satisfy the maximization
21-
function. Our maximization function is to find a subarray that contains at most k zeroes.
22-
23-
To solve this, we maintain a left and right pointer for the sliding window. Also maintain a count of
24-
zeros we've encountered as we expand the sliding window to the right. If the number of zeroes we've
25-
encountered becomes greater than k, while the left pointer is less than or equal to the right
26-
pointer, we shrink the window by incrementing the left pointer. During this process, we also check to
27-
see if we've found another 0 in our subarray. If so, we decrement the count.
28-
29-
These two conditions, zero being less than k and shrinking the window from the left, allows us to
30-
dynamically size the array to search for the correct subarray.
31-
32-
As we traverse the array, we maintain the maximum size of the subarray that satisfies our conditions.
33-
34-
The solution is as follows:
35-
36-
37-
class Solution:
38-
def longestOnes(self, nums: List[int], k: int) -> int:
39-
left = ans = count = 0
40-
41-
for right in range(len(nums)):
42-
if nums[right] == 0: count += 1
43-
44-
while left <= right and count > k:
45-
if nums[left] == 0: count -= 1
46-
left += 1
47-
48-
ans = max(ans, right - left + 1)
49-
50-
return ans
51-
52-
53-
_ Time Complexity:
54-
55-
O(n) - We traverse the array once.
56-
57-
_ Space Complexity:
58-
59-
O(1) - No memory outside of integers are used to maintain the solution.
60-
61-
62-
63-
64-
</pre>
65-
</div>
66-
</body>
1+
<html>
2+
<head>
3+
<title>one2bla.me</title>
4+
<meta charset="utf-8" />
5+
<link href="../../style.css" rel="stylesheet" type="text/css" />
6+
</head>
7+
8+
<body>
9+
<div class="txtdiv">
10+
<pre>
11+
< <a href="index.html">Back</a>
12+
13+
14+
15+
16+
<a href="https://leetcode.com/problems/max-consecutive-ones-iii/">1004. Max Consecutive Ones III</a>
17+
18+
Another sliding window problem, however, the size of the subarray we're looking for isn't statically
19+
defined - the window is dynamic and grows and shrinks depending upon how we satisfy the maximization
20+
function. Our maximization function is to find a subarray that contains at most k zeroes.
21+
22+
To solve this, we maintain a left and right pointer for the sliding window. Also maintain a count of
23+
zeros we've encountered as we expand the sliding window to the right. If the number of zeroes we've
24+
encountered becomes greater than k, while the left pointer is less than or equal to the right
25+
pointer, we shrink the window by incrementing the left pointer. During this process, we also check to
26+
see if we've found another 0 in our subarray. If so, we decrement the count.
27+
28+
These two conditions, zero being less than k and shrinking the window from the left, allows us to
29+
dynamically size the array to search for the correct subarray.
30+
31+
As we traverse the array, we maintain the maximum size of the subarray that satisfies our conditions.
32+
33+
The solution is as follows:
34+
35+
36+
class Solution:
37+
def longestOnes(self, nums: List[int], k: int) -> int:
38+
left = ans = count = 0
39+
40+
for right in range(len(nums)):
41+
if nums[right] == 0: count += 1
42+
43+
while left <= right and count > k:
44+
if nums[left] == 0: count -= 1
45+
left += 1
46+
47+
ans = max(ans, right - left + 1)
48+
49+
return ans
50+
51+
52+
_ Time Complexity:
53+
54+
O(n) - We traverse the array once.
55+
56+
_ Space Complexity:
57+
58+
O(1) - No memory outside of integers are used to maintain the solution.
59+
60+
61+
62+
63+
</pre>
64+
</div>
65+
</body>
66+
</html>

dsa/arrays-and-strings/1094.html

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<html>
2-
3-
<head>
4-
<title>one2bla.me</title>
5-
<meta charset="utf-8">
6-
<link href="../../style.css" rel="stylesheet" type="text/css">
7-
</head>
8-
9-
<body>
10-
<div class="txtdiv">
11-
<pre>
2+
<head>
3+
<title>one2bla.me</title>
4+
<meta charset="utf-8" />
5+
<link href="../../style.css" rel="stylesheet" type="text/css" />
6+
</head>
7+
8+
<body>
9+
<div class="txtdiv">
10+
<pre>
1211
< <a href="index.html">Back</a>
1312

1413

@@ -72,5 +71,6 @@
7271

7372

7473
</pre>
75-
</div>
76-
</body>
74+
</div>
75+
</body>
76+
</html>

dsa/arrays-and-strings/125.html

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
<html>
2-
3-
<head>
4-
<title>one2bla.me</title>
5-
<meta charset="utf-8">
6-
<link href="../../style.css" rel="stylesheet" type="text/css">
7-
</head>
8-
9-
<body>
10-
<div class="txtdiv">
11-
<pre>
12-
< <a href="index.html">Back</a>
13-
14-
15-
16-
17-
<a href="https://leetcode.com/problems/valid-palindrome/">125. Valid Palindrome</a>
18-
19-
We're asked to return True or False if some input string, s, is a Valid Palindrome - after removing
20-
all non-alphanumeric characters and ignoring case. Pretty simple, we use Python's filter() method
21-
and the str.islanum property to filter out all non-alphanumeric characters. Then we convert all
22-
characters to lowercase and check if the string is equal to its reverse.
23-
24-
The solution is as follows:
25-
26-
27-
class Solution:
28-
def isPalindrome(self, s: str) -> bool:
29-
s = ''.join(filter(str.isalnum, s)).lower()
30-
return s == s[::-1]
31-
32-
33-
_ Time Complexity:
34-
35-
O(n) - Where n is the size of s, we traverse the entire string.
36-
37-
_ Space Complexity:
38-
39-
O(n) - We store the sanitized string.
40-
41-
42-
43-
44-
</pre>
45-
</div>
46-
</body>
1+
<html>
2+
<head>
3+
<title>one2bla.me</title>
4+
<meta charset="utf-8" />
5+
<link href="../../style.css" rel="stylesheet" type="text/css" />
6+
</head>
7+
8+
<body>
9+
<div class="txtdiv">
10+
<pre>
11+
< <a href="index.html">Back</a>
12+
13+
14+
15+
16+
<a href="https://leetcode.com/problems/valid-palindrome/">125. Valid Palindrome</a>
17+
18+
We're asked to return True or False if some input string, s, is a Valid Palindrome - after removing
19+
all non-alphanumeric characters and ignoring case. Pretty simple, we use Python's filter() method
20+
and the str.islanum property to filter out all non-alphanumeric characters. Then we convert all
21+
characters to lowercase and check if the string is equal to its reverse.
22+
23+
The solution is as follows:
24+
25+
26+
class Solution:
27+
def isPalindrome(self, s: str) -> bool:
28+
s = ''.join(filter(str.isalnum, s)).lower()
29+
return s == s[::-1]
30+
31+
32+
_ Time Complexity:
33+
34+
O(n) - Where n is the size of s, we traverse the entire string.
35+
36+
_ Space Complexity:
37+
38+
O(n) - We store the sanitized string.
39+
40+
41+
42+
43+
</pre>
44+
</div>
45+
</body>
46+
</html>

dsa/arrays-and-strings/136.html

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<html>
2-
3-
<head>
4-
<title>one2bla.me</title>
5-
<meta charset="utf-8">
6-
<link href="../../style.css" rel="stylesheet" type="text/css">
7-
</head>
8-
9-
<body>
10-
<div class="txtdiv">
11-
<pre>
2+
<head>
3+
<title>one2bla.me</title>
4+
<meta charset="utf-8" />
5+
<link href="../../style.css" rel="stylesheet" type="text/css" />
6+
</head>
7+
8+
<body>
9+
<div class="txtdiv">
10+
<pre>
1211
< <a href="index.html">Back</a>
1312

1413

@@ -48,5 +47,6 @@
4847

4948

5049
</pre>
51-
</div>
52-
</body>
50+
</div>
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)