Skip to content

Conversation

@Phzytaylor
Copy link
Contributor

Added the Swift solutions for the Hash Set and Hashmap chaters

Added the Swift solutions for the Hash Set and Hashmap chaters
Copy link
Collaborator

@Destiny-02 Destiny-02 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Please check the comments

@@ -0,0 +1,31 @@
func geometricSequenceTriplets(_ nums: [Int], _ r: Int) -> Int {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use the same naming convention (UpperCamelCase) as the first set of swift solutions. If lowerCamelCase is more commonly used in swift, you can keep these solutions as is and rename the files in the Two Pointers folders.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lower camelCase is the typical swift convention so I will rename the two pointer files.

for num in nums {
var currentNum = num
var currentChain = 1

Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing comment here
image

@@ -0,0 +1,14 @@
func pairSumUnsorted(nums: [Int], target: Int) -> [Int] {
var dictionary: [Int: Int] = [:]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is "hashmap" a reserved word in swift?
image

@@ -0,0 +1,18 @@
func pairSumUnsortedTwoPass(_ nums: [Int], target: Int) -> [Int] {
var numMap: [Int: Int] = [:]
// First pass: Populate the dictionary with each number and its index
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the chapter is called "Hash Maps and Sets", I think it's ok for the code comment to use "hash map" instead of "dictionary", even if it's called a dictionary in swift

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