본문 바로가기
관리자

Computer Science/Algorithm

(29)
git으로 통합함 https://github.com/CJ0823/python_algorithm_practice
[Leetcode] [작성중] 11. Container With Most Water 1. 문제 You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store. Notice that you may not slant the container. Input: height = [1..
[Leetcode] [미결] 10. Regular Expression Matching 1. 문제 Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single character.​​​​ '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). Example 1: Input: s = "aa", p = "a" Output: false Explanation: "a" does not match the entire string "aa". Example 2: Input:..
[Leetcode] 9. Palindrome Number 1. 문제 Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Example 3: Input: x = 10 Output: false Explan..
[Leetcode] 8. String to Integer (atoi) 비추천이 너무 많아서 살펴보니 쓸데없는 복잡한 케이스를 만들어서 if문을 너무 많이 강제한다는 의견들이 많다. 테스트 자체에 대한 생각 외에 더 이상 탐색하는건 시간 낭비인 문제인 것 같다. 간단해보이는 문제라도 많은 케이스가 존재한다. 처음부터 차분히 풀어야한다. 여러 번 돌려보면서 케이스 스터디를 하는게 낫다. 문제를 푸는 입장이라면 내가 케이스들을 다 생각할 필요가 없다. 영어 해석도 일단 대충하고 실행을 여러 번하는게 낫다. ---------------------------------아래 내용은 안 봐도 됨 1. 문제 Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar ..
[LeetCode] 7. Reverse Integer 1. 문제 Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). Example 1: Input: x = 123 Output: 321 Example 2: Input: x = -123 Output: -321 Example 3: Input: x = 120 Output: 21 Constraint..
[LeetCode][작성중] 6. Zigzag Conversion 1. 문제 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: string convert(string s, int numRows); Example 1: Input: s..
[LeetCode] 3. Longest Substring Without Repeating Characters 1. 문제 Medium Given a string s, find the length of the longest substring without repeating characters. 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 answer is "wke", with the length of 3. Notice..