Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 대학생
- 개발자
- GNN
- 컴퓨터사이언스
- 티스토리챌린지
- Leet Code
- CNN
- 데베
- 코딩테스트
- 자료구조
- sort
- CS
- mysql
- Data_Structure
- meshgraphnet
- Python
- 데이터
- SQL
- db
- 코테
- adaptive remeshing
- 컴퓨터공학
- coding
- code
- LeetCode
- Database
- 데이터베이스
- Mesh
- DS
- 오블완
Archives
- Today
- Total
sy1214ei 님의 블로그
[Leet Code] 500. Keyboard Row - Python 본문
https://leetcode.com/problems/keyboard-row/description/
level : easy
class Solution:
def findWords(self, words: List[str]) -> List[str]:
set1 = {'q','w','e','r','t','y','u','i','o','p'}
set2 = {'a','s','d','f','g','h','j','k','l'}
set3 = {'z','x','c','v','b','n','m'}
res = []
for i in words:
wordset = set(i.lower())
if (wordset&set1 == wordset) or (wordset&set2 == wordset) or (wordset&set3 == wordset):
res.append(i)
return res
# Time Complexity : O(n)
# Space Complexity : O(n)
'[Coding]' 카테고리의 다른 글
| [Leet Code] 3. Longest Substring Without Repeating Characters (0) | 2024.12.16 |
|---|---|
| [Leet Code] 349. Intersection of Two Arrays - Python (0) | 2024.12.16 |
| [Leet Code] 41. First Missing Positive - Python (1) | 2024.12.16 |
| [Leet Code] 409. Longest Palindrome - Python (2) | 2024.12.04 |
| [Leet Code] 1. Two Sum - Python (0) | 2024.12.03 |