leetcode python 13

[leetcode][Medium][Stack] 739. Daily Temperatures 풀이, 해설 (python)

https://leetcode.com/problems/daily-temperatures/ Daily Temperatures - LeetCode Can you solve this real interview question? Daily Temperatures - Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer leetcode.com 1차 풀이 class Solution(object): def dailyTemperatur..

[leetcode][Medium][Stack] 22. Generate Parentheses 힌트, 풀이, 해설 (python)

https://leetcode.com/problems/generate-parentheses/ Generate Parentheses - LeetCode Can you solve this real interview question? Generate Parentheses - Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Exa leetcode.com 힌트 https://www.youtube.com/watch?v=s9fokUqJ76A ..

[leetcode][Medium][Stack] 150. Evaluate Reverse Polish Notation 풀이, 해설 (python)

https://leetcode.com/problems/evaluate-reverse-polish-notation/ Evaluate Reverse Polish Notation - LeetCode Can you solve this real interview question? Evaluate Reverse Polish Notation - You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation [http://en.wikipedia.org/wiki/Reverse_Polish_notation]. Evaluate t leetcode.com 1차 풀이 class Solution..

[leetcode][Medium][Stack] 155. Min Stack 풀이, 해설 (python)

https://leetcode.com/problems/min-stack/ Min Stack - LeetCode Can you solve this real interview question? Min Stack - Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: * MinStack() initializes the stack object. * void push(int val) pushes t leetcode.com 1차 풀이 가벼운 스택 문제일거라 생각했는데, getMin 부분에서 어떻게 O(1)을 만들까 잠깐 고민했다. 그러다가 ..

[leetcode][Easy][Stack] 20. Valid Parentheses 풀이, 해설 (python)

https://leetcode.com/problems/valid-parentheses/ Valid Parentheses - LeetCode Can you solve this real interview question? Valid Parentheses - Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the sam leetcode.com 1차 풀이 단순한 스택 문제라 간단히 풀었지만, 조건이 추가가 되면서 좀 복잡한 풀이가 되..

[leetcode][Hard][Two Pointers] 42. Trapping Rain Water 풀이, 해설 (python) : 해설 참고해서 푼 풀이

https://leetcode.com/problems/trapping-rain-water/ Trapping Rain Water - LeetCode Can you solve this real interview question? Trapping Rain Water - Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: [https://assets.leetcode.com/upl leetcode.com 한시간 정도 풀릴까 말까 하다가, 풀리지 않아서 ... 결국 해설을 본 풀이이다. 일단,..

[leetcode][Medium][Two Pointers] 11. Container With Most Water 풀이, 해설 (python)

https://leetcode.com/problems/container-with-most-water/ Container With Most Water - LeetCode Can you solve this real interview question? Container With Most Water - 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 toget leetcode.com 1차 풀이 일단 단순하게, O(n^2)로 접근했다. 그랬더니 ..

[leetcode] 15. 3Sum 풀이, 해설 (python)

https://leetcode.com/problems/3sum/ 3Sum - LeetCode Can you solve this real interview question? 3Sum - Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain du leetcode.com 1차 풀이 접근법을 못찾아서 O(n*n)으로 푸는 방법을 시도했다. a,b를 찾아서 -(a + b)값이 다른 배열안에 있는지 확인하는 방..

[leetcode] 167. Two Sum II - Input Array Is Sorted 풀이, 해설 (python)

문제 링크 https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/ Two Sum II - Input Array Is Sorted - LeetCode Can you solve this real interview question? Two Sum II - Input Array Is Sorted - Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two n leetcode.com 1차 풀이 단순하게 모..

[leetcode] 125. Valid Palindrome 풀이, 해설 (python)

문제 링크 https://leetcode.com/problems/valid-palindrome/ Valid Palindrome - LeetCode Can you solve this real interview question? Valid Palindrome - A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric cha leetcode.com neetcode 상에서 two pointers로 분류되어 있는 문제이다. 1차 풀이..

반응형