Grind75 - 226. Invert Binary Tree 파이썬
·
알고리즘/LeetCode_Grind75
226. Invert Binary TreeEasyGiven the root of a binary tree, invert the tree, and return its root. Example 1:Input: root = [4,2,7,1,3,6,9]Output: [4,7,2,9,6,3,1]Example 2:Input: root = [2,1,3]Output: [2,3,1]Example 3:Input: root = []Output: [] Constraints:The number of nodes in the tree is in the range [0, 100].-100  나의 코드class TreeNode: def __init__(self, val=0, left=None, right=None): ..
Grind75 - 21. Merge Two Sorted Lists 파이썬
·
알고리즘/LeetCode_Grind75
21. Merge Two Sorted ListsEasyYou are given the heads of two sorted linked lists list1 and list2.Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists.Return the head of the merged linked list. Example 1:Input: list1 = [1,2,4], list2 = [1,3,4]Output: [1,1,2,3,4,4]Example 2:Input: list1 = [], list2 = []Output: []Example 3:Input: li..
Grind75 - 121. Best Time to Buy and Sell Stock 파이썬
·
알고리즘/LeetCode_Grind75
121. Best Time to Buy and Sell StockEasyYou 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 choosing a different day in the future to sell that stock.Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. Example 1:Input: pric..
Grind75 - 242. Valid Anagram 파이썬
·
알고리즘/LeetCode_Grind75
242. Valid Anagram EasyGiven two strings s and t, return true if t is an anagram of s, and false otherwise. Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:Input: s = "rat", t = "car"Output: false Constraints:1 4s and t consist of lowercase English letters. Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case? 나의 코드from col..
컴공편입생 공부일기
'grind75' 태그의 글 목록