일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- condition
- TypeScript
- vuetify
- scss
- leetcode
- npm
- Python
- docker
- type
- nginx
- git
- property
- C++
- 보안
- JavaScript
- dotenv
- var
- VUE
- loop
- vue.js
- bash
- webpack
- AI
- C#
- 앙상블
- machine learning
- Clone
- generic
- security
- BOJ
Archives
- Today
- Total
ice rabbit programming
[LeetCode] 217. Contains Duplocate 본문
728x90
leetcode.com/problems/contains-duplicate/
Contains Duplicate - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
주어진 배열에서, 원소가 두 번 등장하는지를 체크하는 문제이다. 파이썬에서 set은 중복을 허용하지 않는 자료구조임을 이용하여 풀었다.
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
return len(nums) != len(set(nums))
중복이 있다면 길이가 다를 것이고, 중복이 없다면 길이가 같을 것이다.
728x90
'PS > LeetCode' 카테고리의 다른 글
[LeetCode] 242. Valid Anagram (0) | 2022.10.17 |
---|---|
[LeetCode] 231. Power of Two (0) | 2020.12.08 |
[LeetCode] 191. Numbers of 1 Bits (0) | 2020.12.08 |
[LeetCode] 190. Reverse Bits (0) | 2020.12.08 |
[LeetCode] 389. Find the Difference (0) | 2020.12.08 |