일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- VUE
- var
- AI
- webpack
- JavaScript
- vuetify
- condition
- git
- npm
- vue.js
- 앙상블
- generic
- scss
- C#
- 보안
- loop
- BOJ
- bash
- docker
- C++
- nginx
- Python
- TypeScript
- dotenv
- property
- machine learning
- Clone
- security
- leetcode
- type
Archives
- Today
- Total
ice rabbit programming
[LeetCode] 217. Contains Duplocate 본문
leetcode.com/problems/contains-duplicate/
주어진 배열에서, 원소가 두 번 등장하는지를 체크하는 문제이다. 파이썬에서 set은 중복을 허용하지 않는 자료구조임을 이용하여 풀었다.
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
return len(nums) != len(set(nums))
중복이 있다면 길이가 다를 것이고, 중복이 없다면 길이가 같을 것이다.
'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 |