관리 메뉴

솜씨좋은장씨

[leetCode] 2108. Find First Palindromic String in the Array (Python) 본문

Programming/코딩 1일 1문제

[leetCode] 2108. Find First Palindromic String in the Array (Python)

솜씨좋은장씨 2022. 1. 26. 00:42
반응형

코딩 1일 1문제! 오늘의 문제는 leetCode의 Find First Palindromic String in the Array 입니다.

 

Find First Palindromic String in the Array - 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 firstPalindrome(self, words: List[str]) -> str:
        answer = ""
        palindrome_list = [word for word in words if word == word[::-1]]
        
        if len(palindrome_list) != 0:
            answer = palindrome_list[0]
            
        return answer

 

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

반응형
0 Comments
댓글쓰기 폼