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
| _ ._ __/__ _ _ _ _ _/_ Recorded: 18:04:16 Samples: 277 | |
| /_//_/// /_\ / //_// / //_'/ // Duration: 0.277 CPU time: 0.277 | |
| / _/ v4.1.1 | |
| Program: 200_number_of_islands.py | |
| 0.277 <module> <string>:1 | |
| [4 frames hidden] <string>, runpy | |
| 0.277 _run_code runpy.py:64 | |
| └─ 0.277 <module> 200_number_of_islands.py:8 |
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 |