관리 메뉴

솜씨좋은장씨

[leetCode] 2000. Reverse Prefix of Word (Python) 본문

Programming/코딩 1일 1문제

[leetCode] 2000. Reverse Prefix of Word (Python)

솜씨좋은장씨 2022. 1. 28. 00:21
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 leetCode의 Reverse Prefix of Word 입니다.

 

Reverse Prefix of Word - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

👨🏻‍💻 코드 ( Solution )

class Solution:
    def reversePrefix(self, word: str, ch: str) -> str:
        check_idx = word.find(ch)
        if check_idx != -1:
            word = word[:check_idx + 1][::-1] + word[check_idx+1:]
            
        return word

https://github.com/SOMJANG/CODINGTEST_PRACTICE

 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

 

Comments