CtCI-6th-Edition-Swift
CtCI-6th-Edition-Swift copied to clipboard
Cracking the Coding Interview 6th Ed. Swift Solutions
I have created my own Swift solutions for all problems of "Cracking the Coding Interview" 6th edition, bundled in a Swift Package, to make it easy to add as an...
Add input parameter of "of:" to improve readability and match other solutions
https://github.com/careercup/CtCI-6th-Edition-Swift/blob/0dbf24e622df4ef8dbac383711c3b8629a87d477/Ch%202.%20Linked%20Lists/Ch%202.%20Linked%20Lists.playground/Pages/2.1%20Remove%20Duplicates.xcplaygroundpage/Contents.swift#L10-L11 Could be re-written as: ``` guard set.insert($1).inserted else { return $0 } ``` It's more canonical, and makes the value only need to get hashed once.
I thought it is more readable and efficient code. We are already taking the number of string from input. Why we don't use this info?
Solution to 3.6 Animal Shelter question