Last active
January 31, 2019 22:07
-
-
Save andrescabana86/99dc7022ff299c889adae53ec397209a to your computer and use it in GitHub Desktop.
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 deque | |
def compare(a, b): | |
return -1 | |
def sort_horizontal_axis(matrix): | |
result = sorted(matrix, lambda a,b : -1) | |
return result | |
def sort_horizontal_axis_lambda(matrix): | |
matrix.sort(lambda a,b : -1) | |
# complexity O(n) | |
# space O(1) | |
return matrix | |
def flip_horizontal_axis(matrix): | |
result = deque(matrix) | |
result.reverse() | |
return list(result) | |
print(flip_horizontal_axis( | |
[[1,2,3],[4,5,6],[7,8,9]] | |
)) | |
print(sort_horizontal_axis( | |
[[1,2,3],[4,5,6],[7,8,9]] | |
)) | |
print(sort_horizontal_axis( | |
[[1,1,1],[2,2,2],[3,3,3]] | |
)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment