Skip to content

Commit 795036f

Browse files
committed
217. Contains Duplicate
0 parents  commit 795036f

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
## Build generated
6+
build/
7+
DerivedData/
8+
9+
## Various settings
10+
*.pbxuser
11+
!default.pbxuser
12+
*.mode1v3
13+
!default.mode1v3
14+
*.mode2v3
15+
!default.mode2v3
16+
*.perspectivev3
17+
!default.perspectivev3
18+
xcuserdata/
19+
20+
## Other
21+
*.moved-aside
22+
*.xcuserstate
23+
24+
## Obj-C/Swift specific
25+
*.hmap
26+
*.ipa
27+
*.dSYM.zip
28+
*.dSYM
29+
30+
## Playgrounds
31+
timeline.xctimeline
32+
playground.xcworkspace
33+
34+
# Swift Package Manager
35+
#
36+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
37+
# Packages/
38+
.build/
39+
40+
# CocoaPods
41+
#
42+
# We recommend against adding the Pods directory to your .gitignore. However
43+
# you should judge for yourself, the pros and cons are mentioned at:
44+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
45+
#
46+
Pods/
47+
48+
# Carthage
49+
#
50+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
51+
# Carthage/Checkouts
52+
53+
Carthage/Build
54+
55+
# fastlane
56+
#
57+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
58+
# screenshots whenever they are needed.
59+
# For more information about the recommended setup visit:
60+
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
61+
62+
fastlane/report.xml
63+
fastlane/Preview.html
64+
fastlane/screenshots
65+
fastlane/test_output

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Peng Guo
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Swifty Leetcode
2+
3+
Leetcode solutions in Swift.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//: Playground - noun: a place where people can play
2+
3+
import UIKit
4+
5+
/**
6+
* 217. Contains Duplicate
7+
* https://leetcode.com/problems/contains-duplicate/
8+
*/
9+
10+
class Solution {
11+
class func containsDuplicate(nums: [Int]?) -> Bool {
12+
guard let nums = nums, nums.count != 0, nums.count != 1 else { return false }
13+
14+
return nums.count > Set(nums).count
15+
}
16+
17+
}
18+
19+
/*:
20+
### Usage
21+
*/
22+
23+
let nums1 = [1, 5, 27, 8, 3, 186, 12, 22, 8, 962]
24+
Solution.containsDuplicate(nums: nums1)
25+
26+
let nums2 = [3, 9, 32, 16, 0, 125, 1457, 83]
27+
Solution.containsDuplicate(nums: nums2)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='ios' display-mode='raw'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

0 commit comments

Comments
 (0)