###### tags: `LeetCode`,`Java`,`Easy` # Easy-217. Contains Duplicate ### **題目連結:** [**Contains Duplicate**](https://leetcode.com/problems/contains-duplicate/) ### **解題方向** * 運用set不能存放重複值的特性來完成此題目 ### **完整程式碼** ```java= import java.util.*; class Solution { public boolean containsDuplicate(int[] nums) { Set setTest = new HashSet(); for(int i=0;i<nums.length;i++){ if(!setTest.add(nums[i]))return true; } return false; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up