Algorithm/기본 알고리즘

leetcode 28. Find the index of the First Occurence in a String

용자대디 2023. 1. 21. 15:45

https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/

미디움이라고 하지만, 전혀 미디움 난이도가 아닌 문제

class Solution(object):
    def strStr(self, haystack, needle):
        """
        :type haystack: str
        :type needle: str
        :rtype: int
        """
        if needle in haystack :
            return haystack.index(needle)
        
        return -1

'Algorithm > 기본 알고리즘' 카테고리의 다른 글

leetcode 94. Binary Tree Inorder Traversal  (0) 2023.01.22
leetcode 24. Swap Nods in Pairs  (0) 2023.01.21
boj-1931. 회의실배정  (0) 2023.01.20
boj-5397. 키 로거  (0) 2023.01.20
boj-7785. 회사에있는사람  (0) 2023.01.20