[Python/LeetCode]코딩테스트 준비를 위한 파이썬 알고리즘 문제 11. Container With Most Water 해설(Medium level)
2020. 1. 21. 12:23
알고리즘 문제
문제 11. Container With Most Water Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You may not slant the container and n is at least 2. Loo..
[Python/LeetCode]코딩테스트 준비를 위한 파이썬 알고리즘 문제 7.Reverse integer 해설(Easy level)
2020. 1. 19. 18:53
알고리즘 문제
문제 7. Reverse integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note:Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that your function returns 0 when ..
[Python/LeetCode]코딩테스트 준비를 위한 파이썬 알고리즘 문제 5.Longest Palindromic Substring 참조해설(Medium level)
2020. 1. 19. 01:39
알고리즘 문제
문제 5. Longest palindromic substring Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd" Output: "bb" 오늘 해설의 idea는 "Chomolungma" 라는 유저의 글을 참고하였습니다. def longestPalindrome(s): #문자열이 공백인 경우 그대로 출력 if len(s)==0: return s flag=1 start=0 #문..
[Python/LeetCode]코딩테스트 준비를 위한 파이썬 알고리즘 문제 4.Median of Two Sorted Arrays 해설(High level)
2020. 1. 18. 21:02
알고리즘 문제
문제 4. Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 Example 2: nums1 = [1, 2] nums2 = [3, 4] The median is (2 + 3)/2 = 2.5 두 개의 sorted ..
[Python/LeetCode]코딩테스트 준비를 위한 파이썬 알고리즘 문제 3.longest substring without repeating characters 해설(medium level)
2020. 1. 18. 18:10
알고리즘 문제
문제 3. longest substring without repeating characters Given a string, find the length of the longest substring without repeating characters. Example 1:Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2:Input: "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3:Input: "pwwkew" Output: 3 Explanation: The answer is "wke", with ..
[Python/LeetCode]코딩테스트 준비를 위한 파이썬 알고리즘 문제 1.twoSum 해설(easy level)
2020. 1. 15. 00:06
알고리즘 문제
문제 1. twoSum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. int 자료형으로 구성된 list의 요소끼리 서로 더했을 때 target이 되는 경우를 찾고, 해당하는 값의 index를..
[Python/NLP]파이썬을 이용해 웹문서(HTML)를 PDF로 변환하기
2020. 1. 14. 22:43
Data/Data Engineering
웹문서를 PDF로 변환해 저장해야할 때가 있습니다. 이럴때를 위해 준비된 Python 라이브러리를 소개합니다. import pdfcrowd import sys 오늘 사용될 라이브러리는 pdfcorwd 로 https://pdfcrowd.com/doc/api/html-to-pdf/python/자세한 사용법은 하단 링크를 확인하시면 됩니다. HTML to PDF API for Python | Pdfcrowd top Set the output page top margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). Default: 0.4in right Set the output page right mar..