본문 바로가기

Python36

[코딩테스트]리트코드 14 - Longest Common Prefix (Easy) in Python Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". 문자열의 배열이 매개변수로 주어졌을 때, 공통된 가장 긴 접미사를 반환하세요. Example 1: Input: strs = ["flower","flow","flight"] Output: "fl" Constraints: 1 2021. 5. 29.
[코딩 테스트] 리트코드 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.
[코딩 테스트] 리트코드 4 - Median of Two Sorted Arrays (Hard) in Python Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 두 정렬된 배열들 num1와 nums2가 주어질 때, 둘의 median 값을 리턴하라. Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2. Example 2: Input: nums1 = [1,2], nums2 = [3,4] Output: 2.50000 Ex.. 2021. 5. 22.
[코딩 테스트] 리트코드 3 - Longest Substring without Repeating Characters (Medium) in Python Given a string s, find the length of the longest substring without repeating characters 문자열 s가 주어졌을 때, 반복되지 않는 문자로 이뤄진 가장 긴 부분문자열의 길이를 리턴하세요! Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answe.. 2021. 5. 22.