-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Create 2017-grid-game.js #2545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create 2017-grid-game.js #2545
Conversation
Solved grid-game in JS.
javascript/2017-grid-game.js
Outdated
*/ | ||
var gridGame = function(grid) { | ||
|
||
const preSum1 = [0]; |
There was a problem hiding this comment.
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()
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant comments
I see someone has added a better solution to this problem here. I'm closing the PR. |
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/