| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 29 | 30 |
Tags
- 앙상블
- security
- VUE
- docker
- scss
- var
- type
- nginx
- property
- vuetify
- BOJ
- leetcode
- condition
- loop
- machine learning
- dotenv
- TypeScript
- bash
- JavaScript
- npm
- git
- AI
- C++
- C#
- Python
- 보안
- vue.js
- Clone
- webpack
- generic
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 |