Last active
June 12, 2024 02:49
-
-
Save talhaahussain/bad86fce26afdc239af4af9eab23167b to your computer and use it in GitHub Desktop.
contiguous_subarrays.py -- A simple, type-hinted solution using list comprehension for generating all contiguous subarrays of any homogeneous or non-homogeneous list across one dimension. Does not return the original 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
def generate_subarrays(a: list[any]) -> list[any]: | |
return [a[i:j] for i in range(len(a)) for j in range(i + 1, len(a) + 1)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment