본문 바로가기

Problem Solving10

[Leetcode] 226. Invert Binary Tree Problem Link: https://leetcode.com/problems/invert-binary-tree/ Invert Binary Tree - LeetCode Can you solve this real interview question? Invert Binary Tree - Given the root of a binary tree, invert the tree, and return its root. Example 1: [https://assets.leetcode.com/uploads/2021/03/14/invert1-tree.jpg] Input: root = [4,2,7,1,3,6,9] Output: [4 leetcode.com Solution 1. Recursion (DFS) Time: $O(.. 2023. 7. 13.
[Leetcode] 125. Valid Palindrome Problem Link: 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 Solution 1. Two Pointers Time: $O(N)$ .. 2023. 7. 12.
[Leetcode] 121. Best Time to Buy and Sell Stock Problem Link: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/ Best Time to Buy and Sell Stock - LeetCode Can you solve this real interview question? Best Time to Buy and Sell Stock - You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosin leetcode... 2023. 7. 12.
[Leetcode] 20. Valid Parentheses Problem Link: 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 Solution 1. Stack Python의 list에서 app.. 2023. 7. 11.