Last active
August 20, 2020 04:11
-
-
Save ellisandrews/21bc592a45e26b67782ba71075cb578a to your computer and use it in GitHub Desktop.
Constant time complexity
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 Any, Dict, List | |
# Example 1 | |
def list_lookup(list_: List[Any], index: int) -> Any: | |
"""Lookup a value in a list by index.""" | |
return list_[index] | |
# Example 2 | |
def dict_lookup(dict_: Dict[Any, Any], key: Any) -> Any: | |
"""Lookup a value in a dictionary by key.""" | |
return dict_[key] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment