This file contains 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 | |
from typing import Tuple | |
def daily_temperatures(temperatures: List[int]) -> List[int]: | |
""" | |
Calculates, for each day, the number of days expected until a warmer temperature. | |
If there is no future day for which a temperature is warmer, a 0 is returned. | |
:param temperatures: List of daily temperatures. | |
:return: List where each element is the number of days to wait for a warmer temperature. |
This file contains 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 has_unique_digits(number: int) -> bool: | |
""" | |
Check if the given number has all unique digits. | |
Args: | |
number (int): The number to check. | |
Returns: | |
bool: True if all digits are unique, False otherwise. | |
""" |
This file contains 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 | |
def count_vowels(name: str) -> int: | |
"""Helper function to count the number of vowels in a name.""" | |
vowels = "aeiouAEIOU" | |
return sum(1 for char in name if char in vowels) | |
def clean_names(names: List[str]) -> None: | |
"""Helper function to remove non-string elements from the list.""" |
This file contains 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 itertools import combinations | |
from typing import List | |
def four_sum(nums: List[int], target: int) -> List[List[int]]: | |
""" | |
Finds all unique quadruplets in the list that sum up to the target value. | |
Args: | |
nums (List[int]): The list of integers. | |
target (int): The target sum for the quadruplets. |
This file contains 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 | |
def only_evens(numbers: List[int]) -> List[int]: | |
""" | |
Returns a sorted list of even numbers from the input list. | |
Args: | |
numbers (list of int): List of integers. | |
Returns: | |
list of int: Sorted list of even integers. | |
""" |