-
Notifications
You must be signed in to change notification settings - Fork 88
Go: Chapter 2 Hash Maps and Sets #56
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
Go: Chapter 2 Hash Maps and Sets #56
Conversation
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.
Hi @ineBallardin, thank your for making a PR to the solutions repository! Please check the comments for the the change(s) requested.
Thanks again for your contributions! 🙂
@@ -0,0 +1,29 @@ | |||
package hashmapsandsets | |||
|
|||
func LongestChainOfConsecutiveNumbers(nums []int) int { |
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.
should the function names use camel case?
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.
PascalCase/UpperCamelCase is used in these solutions instead of lowerCamelCase. Are there conventions around which one is used for regular functions?
@@ -0,0 +1,29 @@ | |||
package hashmapsandsets | |||
|
|||
func LongestChainOfConsecutiveNumbers(nums []int) int { |
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.
PascalCase/UpperCamelCase is used in these solutions instead of lowerCamelCase. Are there conventions around which one is used for regular functions?
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.
LGTM! Just check the comment left by @aikhelis
Use `return []int{}` instead of `return nil` in order to keep consistency with origial Python solition.
return []int{i, idx} | ||
} | ||
} | ||
return nil |
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.
Apologies, I forgot to leave here the same suggestion to return an empty list instead of nil.
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'm resolving this comment, as per our chat in Discord: Returning nil
is a common and idiomatic way in Go to indicate the absence of a result, as it differentiates between "no result" and "an empty result."
We should keep 'nil' here.
} | ||
hashmap[x] = i | ||
} | ||
return []int{} |
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.
Apologies. I'm removing this suggestion per our chat in Discord: Returning nil
is a common and idiomatic way in Go to indicate the absence of a result, as it differentiates between "no result" and "an empty result."
We should keep 'nil' here.
Return `nil` instead of `return []int{}`
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.
LGTM! Thank you, great job, Karine @ineBallardin !
Go Solutions for Chapter 2 - Hash Maps and Sets
This PR adds Go solutions for Chapter 2 - Hash Maps and Sets.
I followed the structure and naming conventions used in the official Python solutions to maintain consistency across languages. However, for variable and function names, I applied Go idiomatic conventions (e.g.,
camelCase
for variables and functions,snake_case
for file names). Despite these adaptations, the names remain equivalent to the original solutions to ensure clarity and consistency.All implementations have been tested to match the expected outputs. Let me know if any adjustments are needed!