Grid Challenge Discussions | Algorithms | HackerRank

Grid Challenge

Sort by

recency

|

602 Discussions

|

  • + 0 comments

    You say in input description n lines of string of length n.

    But in the sample testcase itself you give input with n = 4 but string length as 3.

    Either correct the Testcases of problem description.

  • + 0 comments

    Before redeeming any promo code on CSGO500, I check the terms: Is there a deposit needed? Are there playthrough requirements? When I found TOP100LIST on https://cyber-sport.io/csgo500-promo-code, it clearly explained all that. That’s why it worked for me without surprises. I didn’t need to gamble a huge amount to unlock the bonus. Sites like Cyber-Sport.io take the guesswork out of promo codes, making sure users know exactly what they’re getting into before they click “redeem.”

  • + 0 comments

    My solution, it might complex

    def gridChallenge(grid):
        # Sort each row
        for idx in range(len(grid)):
            strList = list(grid[idx])
            strList.sort()
            grid[idx] = "".join(strList)
        # Join all grid list to a single string
        strJoin = "".join(grid)
        gLength = len(grid)
    		# Create the column list based on grid length
        reverseGrid = [0] * len(grid)
        for i in range(len(strJoin)):
    		    # get the ascii code
            curr = ord(strJoin[i])
    				# Get the saved grid ascii code based on index % length
            prev = reverseGrid[i % gLength]
            diff = curr - prev
    				# if the diff < 0, means current ascii value less than previous, which means it's not in order
            if diff < 0:
                return "NO"
    
            reverseGrid[i % gLength] = curr
        return "YES" 
    
  • + 0 comments

    python easy solution:

    def gridChallenge(grid):
        # Sort each row
        sorted_grid = [''.join(sorted(row)) for row in grid]
        
        # Zip to get columns
        for col in zip(*sorted_grid):
            if list(col) != sorted(col):
                return "NO"
        return "YES"
    
  • + 0 comments

    It's NOT square matrix. Problem Description is Bad