<jupyter_start><jupyter_text>2020년 5월 18일 월요일 leetCode - String to Integer (atoi) 문제 : https://leetcode.com/problems/string-to-integer-atoi/ 블로그 : https://somjang.tistory.com/entry/leetCode-8-String-to-Integer-atoi-Python  첫번째 시도<jupyter_code>import re

class Solution:
    def myAtoi(self, string) -> int:
        answer = 0
        
        string = string.strip()
    
        if string == "":
            answer = 0
        else:
            string_list = list(string)

            if string_list[0] == '-':
                isMinus = True


            number_list = re.findall(r"^[-+]?[0-9]+", string)

            print(number_list)

            if len(number_list) == 0:
                answer = 0
            else:
                number = int(number_list[0])
                if number > pow(2, 31) - 1:
                    number = pow(2, 31) -1
                elif number < pow(2, 31) * (-1):
                    number = pow(2, 31) * (-1)

                answer = number
        
        return answer<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1235632183908046, 'fraction_numerical': 0.03065134099616858, 'mean_word_length': 1.470449172576832, 'pattern_counts': {'":': 1, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '531534', 'license': 'MIT', 'n_tokens_mistral': 375, 'n_tokens_neox': 355, 'n_words': 71, 'path': 'DAY 101 ~ 200/DAY102_[leetCode] String to Integer (atoi) (Python).ipynb', 'repo_name': 'SOMJANG/CODINGTEST_PRACTICE', 'size': '1044'}