관리 메뉴

솜씨좋은장씨

[leetCode] 1291. Sequential Digits (Python) 본문

Programming/코딩 1일 1문제

[leetCode] 1291. Sequential Digits (Python)

솜씨좋은장씨 2022. 1. 25. 00:45
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 leetCode의 Sequential Digits 입니다.

 

Sequential Digits - 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 sequentialDigits(self, low: int, high: int) -> List[int]:
        answer = []
        num_string = "123456789"
        
        min_len, max_len = len(str(low)), len(str(high))
        
        for i in range(min_len, max_len + 1):
            for j in range(len(num_string) - i + 1):
                if low <= int(num_string[j:j+i]) <= high:
                    answer.append(int(num_string[j:j+i]))
                    
        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

Comments