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
- recursive
- binary tree
- two pointers
- 중간
- math
- HashTable
- Binary
- matrix
- Depth-first Search
- 미디움
- Python
- binary search
- hash table
- leetcode
- 쉬움
- 재귀
- DP
- Array
- backtracking
- string
- linked list
- 이진트리
- sorting
- tree
- easy
- list
- 리트코드
- 문자열
- dfs
- Medium
Archives
- Today
- Total
목록leeetcode58 (1)
부부의 코딩 성장 일기
LeetCode 58(Length of Last Word, Python)
1. 문제 링크 https://leetcode.com/problems/length-of-last-word/ 2. 문제 설명 단어와 공백으로 구성된 문자열 s가 주어졌을 때, 가장 마지막 단어의 길이를 반환 예시) s = "Hello World", output: 5 (마지막 단어인 "World"의 길이 5 반환) 3. 처음 풀이 문자열에 대한 관련 함수를 이미 알고 있어서, 간단하게 해결. s의 양쪽 공백을 없애고, ' ' 기준 split을 한 후, 마지막 element의 lenght를 반환 class Solution: def lengthOfLastWord(self, s: str) -> int: return len(s.strip().split(' ')[-1]) # 양 쪽 공백을 없애고, ' '기준으로 s..
Algorithm/LeetCode
2023. 11. 7. 19:00