본문 바로가기

코테4

[코딩 테스트] 리트코드 13 - Roman to Integer (Easy) in Python 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 Example 1: Input: s = "III" Output: 3 Example 2: Input: s = "IV" Output: 4 Example 3: Input: s = "IX" Output: 9 Example 4: Input: s = "LVIII" Output: 58 Explanation: L = 50, V= 5, III = 3. Example 5: Input: s = "MCMXCIV" Output: 1994 Explana.. 2021. 5. 22.
[코딩 테스트] 리트코드 1 - Two Sum (Easy) in Python Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. 2 List[int]: hashTable = {} for i in range(len(nums)): complement = target - nums[i] if complement in hashTable: return [i, hashTable[complement]] hashTable[nums[i]] = .. 2021. 5. 22.
[코딩테스트] 리트코드 - 17. Letter Combinations of a Phone Number 문제 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. 2-9 번호에 해당하는 알파벳이 있다. 인풋으로 2-9를 포함한 문자열이 주어질 때, 각 숫자가 나타낼 수 있는 문자들의 조합을 구하여라! Constraints: •0 2021. 4. 10.
[코딩테스트] 리트코드(LeetCode) - Longest Palindromic Substring - Python, JS 문제 Given a string s, return the longest palindromic substring in s. 문자열 s가 주어졌을 때, 팰린드롬이 되는 가장 긴 부분문자열 리턴. 예시 1. 입력 s = "babad" 출력 "bab" 혹은 "aba" 2. 입력 s = "baad" 출력 "aa" 3. 입력 s = "a" 출력 "a" => 예시들에서 볼 수 있는 것은, 짝수개문자열, 혹은 한글자도 팰린드롬 취급을 하는 것이다. 조건 - s의 길이는 최대 1000. •https://leetcode.com/problems/longest-palindromic-substring/ 풀이 LeetCode에는 다섯가지의 풀이 방법이 주어진다. 1. Longest Common Substring - 주어진 문자열.. 2021. 3. 30.