Skip to content

Conversation

aadil42
Copy link
Contributor

@aadil42 aadil42 commented Jun 7, 2023

Solved grid-game in JS.

File(s) Added: 2017-grid-game.js
Language(s) Used: JavaScript
Submission URL: https://leetcode.com/problems/grid-game/submissions/985274543/

Solved grid-game in JS.
*/
var gridGame = function(grid) {

const preSum1 = [0];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: break up into modular functions

main = () => {
    preCompute()

    return search()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have split them into modules please have a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a kind reminder that I updated the code as suggested.

Splitting code into modules for better readability.
}

// Main function to calculate the minimum result
function gridGame(grid) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move main function to the top of file.

* @return {number}
*/

// Calculate the prefix sums for a given row in the grid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant comments

@aadil42
Copy link
Contributor Author

aadil42 commented Sep 5, 2023

I see someone has added a better solution to this problem here. I'm closing the PR.

@aadil42 aadil42 closed this Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants