일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 구글퀵랩
- Microsoft
- 파이썬알고리즘
- LeetCode
- sql코테
- 파이썬
- stratascratch
- SQL
- GenerativeAI
- 자연어처리
- 투포인터
- nlp
- dfs
- 파이썬기초100제
- 알고리즘
- 슬라이딩윈도우
- 니트코드
- GenAI
- heap
- 코드업
- Python3
- two-pointer
- slidingwindow
- codeup
- Python
- 생성형AI
- medium
- gcp
- 릿코드
- 리트코드
- Today
- Total
목록algorithm (2)
Tech for good

class Solution: def rotate(self, nums: List[int], k: int) -> None: n = len(nums) k = k % n # In case k is larger than n # Step 1: Reverse the entire array nums.reverse() # Step 2: Reverse the first k elements nums[:k] = reversed(nums[:k]) # Step 3: Reverse the remaining n-k elements nums[k:] = reversed(nums[k:]) ..

class Solution: def isPrefixOfWord(self, sentence: str, searchWord: str) -> int: words = sentence.split() for i, word in enumerate(words): if word.startwith(searchword): return i+1 return -1 Explanation:Split the Sentence: The input sentence is split into a list of words using .split(), which automatically handles single spaces.Iterate Over Words..