python34 LeetCode 412. Fizz Buzz - Python 문제 Given an integer n, return a string array answer (1-indexed) where: answer[i] == "FizzBuzz" if i is divisible by 3 and 5. answer[i] == "Fizz" if i is divisible by 3. answer[i] == "Buzz" if i is divisible by 5. answer[i] == i (as a string) if none of the above conditions are true. Example 1: Input: n = 3 Output: ["1","2","Fizz"] Example 2: Input: n = 5 Output: ["1","2","Fizz","4","Buzz"] Examp.. 2022. 9. 5. LeetCode 383. Ransom Note - Python '383. Ransom Note'는 문자열 ransomNote가 문자열 magazine이 가진 문자로 만들 수 있는지 판별하는 문제이다. 문제 Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. Each letter in magazine can only be used once in ransomNote. Example 1: Input: ransomNote = "a", magazine = "b" Output: false Example 2: Input: ransomNote = "aa", magazine = .. 2022. 9. 5. LeetCode 234. Palindrome Linked List - Python '234. Palindrome Linked List'는 singly linked list가 input으로 주어진 문제이다. 문제 Given the head of a singly linked list, return true if it is a palindrome or false otherwise. Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false Constraints: The number of nodes in the list is in the range [1, 105]. 0 bool: heads = deque() while head: heads.append(head.val) head = he.. 2022. 9. 4. LeetCode 13. Roman to Integer - Python '13. Roman to Integer'는 LeetCode에 처음 가입하면 나오는 'Challenges for New Users' 리스트의 첫 문제이다. 초보자를 위한 문제이니만큼 정말 쉽다. 딱히 알고리즘이라 할만한 것도 없다. 문제 Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written as XII, which is simply X + II. The num.. 2022. 9. 3. 이전 1 다음