본문 바로가기

부부의 코딩 성장 일기

검색하기
부부의 코딩 성장 일기
프로필사진 펩시_콜라

  • 분류 전체보기 (147)
    • Algorithm (135)
      • LeetCode (135)
    • Python (6)
      • Fundamentals (5)
      • Libraries (1)
Guestbook
Notice
Recent Posts
Recent Comments
Link
«   2026/01   »
일 월 화 수 목 금 토
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
  • binary search
  • leetcode
  • backtracking
  • Medium
  • 중간
  • Binary
  • matrix
  • HashTable
  • 쉬움
  • easy
  • list
  • 이진트리
  • 리트코드
  • two pointers
  • linked list
  • 문자열
  • hash table
  • binary tree
  • sorting
  • 미디움
  • Python
  • DP
  • recursive
  • string
  • Depth-first Search
  • Array
  • math
  • tree
  • dfs
  • 재귀
more
Archives
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록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
이전 Prev 1 Next 다음

Blog is powered by kakao / Designed by Tistory

티스토리툴바