Skip to content

Instantly share code, notes, and snippets.

@andrescabana86
Last active January 31, 2019 22:07
Show Gist options
  • Save andrescabana86/99dc7022ff299c889adae53ec397209a to your computer and use it in GitHub Desktop.
Save andrescabana86/99dc7022ff299c889adae53ec397209a to your computer and use it in GitHub Desktop.
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