You are viewing a single comment's thread. Return to all comments →
Typescript
function sortString(str: string) { return str.split('').sort(); } function gridChallenge(grid: string[]): string { const sortedGrid = [] as any; for (let ele of grid) { sortedGrid.push(sortString(ele)); } for (let i = 0; i < sortedGrid.length; i++) { for (let j = 0; j < sortedGrid[i].length - 1; j++) { if (sortedGrid[j + 1][i] < sortedGrid[j][i]) { return 'NO'; } } } return 'YES'; }
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 →
Typescript