We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def gridChallenge(grid):
# Write your code here
temp = []
def check_row_order(grid):
for i in range(len(grid)):
grid[i] = sorted(grid[i])
temp.extend(grid[i])
return grid
rowsorted = check_row_order(grid)
print(rowsorted)
base =[]
total = len(rowsorted) * len(rowsorted[0])
for i in range(len(rowsorted[0])):
base.append([temp[k] for k in range(i, total, len(rowsorted[0]))])
for i in base:
if i!= sorted(i):
return 'NO'
else:
return 'YES'
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Grid Challenge
You are viewing a single comment's thread. Return to all comments →
Another Pythonic Way
def gridChallenge(grid): # Write your code here temp = []