This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
class Solution: | |
def numIslands(self, grid: List[List[str]]) -> int: | |
"""Find number of islands in grid. | |
Args: | |
grid (List[List[str]]): Grid with 0s and 1s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
class Solution: | |
def lengthOfLongestSubstring(self, s: str) -> int: | |
"""Count longest sequence with no repeating characters | |
Args: | |
s (str): String to analyze |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
class Solution: | |
def twoSum(self, nums: List[int], target: int) -> List[int]: | |
"""Find indexes of numbers that sum to target number. | |
Args: | |
nums (List[int]): List of numbers to consider. | |
target (int): Number to sum to. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
class Solution: | |
def characterReplacement(self, s: str, k: int) -> int: | |
"""Calculate the longer repeating character | |
string when replacing with one letter | |
Args: | |
s (str): String to evaluate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from typing import List | |
class Solution: | |
def characterReplacement(self, s: str, k: int) -> int: | |
"""Calculate the longer repeating character | |
string when replacing with one letter | |
Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_length(self, diffs: List[int], k: int) -> int: | |
"""Calculate maximum sequence length based | |
on the differences between character positions | |
Args: | |
diffs (List[int]): List of position differences | |
k (int): Number of characters to replace | |
Returns: | |
int: Maximum length of replacement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_length(self, diffs: List[int], k: int) -> int: | |
"""Calculate maximum sequence length based | |
on the differences between character positions | |
Args: | |
diffs (List[int]): List of position differences | |
k (int): Number of characters to replace | |
Returns: | |
int: Maximum length of replacement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
class Solution: | |
def characterReplacement(self, s: str, k: int) -> int: | |
"""Calculate the longer repeating character | |
string when replacing with one letter | |
Args: | |
s (str): String to evaluate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
class Solution: | |
def findMin(self, nums: List[int]) -> int: | |
"""Find minimum element in rotated sorted array. | |
Args: | |
nums (List[int]): Rotated sorted array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
class Solution: | |
def maxArea(self, height: List[int]) -> int: | |
"""Calculate max area between array elements. | |
Args: | |
height (List[int]): List of heights |