PS/Leetcode

PS/Leetcode

[C++] 1847. Closest Room

Leetcode 바로가기 : 1847. Closest Room Description There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [\(roomId_i\), \(size_i\)] denotes that there is a room with room number roomIdi and size equal to sizei. Each roomIdi is guaranteed to be unique. You are also given k queries in a 2D array queries where queries[j] = [\(preferred_j\), \(minSize_j\)]..

PS/Leetcode

[C++] 150. Evaluate Reverse Polish Notation

Leetcode 바로가기 : 150. Evaluate Reverse Polish Notation Description You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation. Evaluate the expression. Return an integer that represents the value of the expression. Note that: ▪ The valid operators are '+', '-', '*', and '/'. ▪ Each operand may be an integer or another expression. ▪ The division ..

PS/Leetcode

[C++] 1143. Longest Common Subsequence

Leetcode 바로가기 : 1143. Longest Common Subsequence Description Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. For example, "ace..

PS/Leetcode

[Python] 198. House Robber

Leetcode 바로가기 : 198. House Robber Description You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night. Given an integ..

PS/Leetcode

[Python] 70. Climbing Stairs & 931. Minimum Falling Path Sum

💚 Leetcode 바로가기 : 70. Climbing Stairs ▪ Description You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? ▪ Example 1 Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps ▪ Example 2 Input: n = 3 Output: 3 Explanation: There are three wa..

PS/Leetcode

[Python] 938. Range Sum of BST & 872. Leaf-Similar Trees

Leetcode 바로가기 : 938. Range Sum of BST ▪ Description Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. ▪ Example 1 Input: root = [10,5,15,3,7,null,18], low = 7, high = 15 Output: 32 Explanation: Nodes 7, 10, and 15 are in the range [7, 15]. 7 + 10 + 15 = 32. ▪ Example 2 Input: root = [1..

PS/Leetcode

[Python] 876. Middle of the Linked List & 328. Odd Even Linked List

Leetcode 바로가기 : 876. Middle of the Linked List ▪ Description Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. ▪ Example 1 Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: The middle node of the list is node 3. ▪ Example 2 Input: head = [1,2,3,4,5,6] Output: [4,5,6] Explanation: Since the list ha..

PS/Leetcode

[Python] 1464. Maximum Product of Two Elements in an Array

Leetcode 바로가기 : 1464. Maximum Product of Two Elements in an Array ▪ Description Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). ▪ Example 1 Input: nums = [3,4,5,2] Output: 12 Explanation: If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums[1]-1)*(..

PS/Leetcode

[Python] 451. Sort Characters By Frequency

Leetcode 바로가기 : 451. Sort Characters By Frequency ▪ Description Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the sorted string. If there are multiple answers, return any of them. ▪ Example 1 Input: s = "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and '..

PS/Leetcode

[Python] 1704. Determine if String Halves Are Alike

Leetcode 바로가기 : 1704. Determine if String Halves Are Alike ▪ Description You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half. Two strings are alike if they have the same number of vowels ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Notice that s contains uppercase and lowercase letters. Return tr..

하다밍
'PS/Leetcode' 카테고리의 글 목록