일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- slidingwindow
- 자연어처리
- 리트코드
- heap
- 파이썬알고리즘
- Python3
- Greedy
- 투포인터
- 릿코드
- 생성형AI
- SQL
- codeup
- 파이썬
- 슬라이딩윈도우
- 니트코드
- 코드업
- LeetCode
- Stack
- 알고리즘
- GenAI
- sql코테
- gcp
- GenerativeAI
- 파이썬기초100제
- two-pointer
- nlp
- dfs
- Python
- stratascratch
- array
Archives
- Today
- Total
Tech for good
[CodePath] Unit 1: Strings and Arrays - Unique 본문
def has_all_unique_characters(s):
unique_chars = set(s)
if len(s) == len(unique_chars):
return True
else:
return False
Using Sets
- Sets are collections of unique elements. You can convert a string into a set to get its unique characters.
- The order of characters is not guaranteed in a set.
text = "programming"
unique_chars = set(text)
print(unique_chars) # Output: {'g', 'r', 'a', 'm', 'p', 'i', 'n', 'o'}
'IT > Computer Science' 카테고리의 다른 글
[Neetcode/Brute-force, Hashmap] Two Sum (0) | 2025.06.24 |
---|---|
[Leetcode/Stack] 1047. Remove All Adjacent Duplicates In String (0) | 2025.06.11 |
[Leetcode/Greedy] 55. Jump Game (1) | 2025.06.09 |
[Leetcode/Linked List] 206. Reverse Linked List (0) | 2025.06.03 |
[Leetcode/Graph (In-Degree/Out-Degree)] 277. Find the Celebrity (0) | 2025.06.02 |