-
Notifications
You must be signed in to change notification settings - Fork 178
Swift Hash Set and Hashmap Solutions #107
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
base: main
Are you sure you want to change the base?
Swift Hash Set and Hashmap Solutions #107
Conversation
Added the Swift solutions for the Hash Set and Hashmap chaters
Destiny-02
left a comment
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.
Thanks for the PR! Please check the comments
| @@ -0,0 +1,31 @@ | |||
| func geometricSequenceTriplets(_ nums: [Int], _ r: 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.
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.
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 | ||
|
|
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.
| @@ -0,0 +1,14 @@ | |||
| func pairSumUnsorted(nums: [Int], target: Int) -> [Int] { | |||
| var dictionary: [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.
| @@ -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 | |||
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.
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



Added the Swift solutions for the Hash Set and Hashmap chaters