This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/simplify-path/description/ | |
| # 71. Simplify Path | |
| # Given a string path, which is an absolute path (starting with a slash '/') to a file or directory in a Unix-style file system, convert it to the simplified canonical path. | |
| # In a Unix-style file system, a period '.' refers to the current directory, a double period '..' refers to the directory up a level, and any multiple consecutive slashes (i.e. '//') are treated as a single slash '/'. For this problem, any other format of periods such as '...' are treated as file/directory names. | |
| # The canonical path should have the following format: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/coin-change/description/ | |
| # 322. Coin Change | |
| # You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. | |
| # Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. | |
| # You may assume that you have an infinite number of each kind of coin. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/beautiful-towers-i/ | |
| # 2865. Beautiful Towers I | |
| # You are given a 0-indexed array maxHeights of n integers. | |
| # You are tasked with building n towers in the coordinate line. The ith tower is built at coordinate i and has a height of heights[i]. | |
| # A configuration of towers is beautiful if the following conditions hold: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/design-circular-queue/description/ | |
| # 622. Design Circular Queue | |
| # Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle, and the last position is connected back to the first position to make a circle. It is also called "Ring Buffer". | |
| # One of the benefits of the circular queue is that we can make use of the spaces in front of the queue. In a normal queue, once the queue becomes full, we cannot insert the next element even if there is a space in front of the queue. But using the circular queue, we can use the space to store new values. | |
| # Implement the MyCircularQueue class: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/employee-importance/ | |
| # 690. Employee Importance | |
| # You have a data structure of employee information, including the employee's unique ID, importance value, and direct subordinates' IDs. | |
| # You are given an array of employees employees where: | |
| # employees[i].id is the ID of the ith employee. | |
| # employees[i].importance is the importance value of the ith employee. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ | |
| # Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree. | |
| # Example 1: | |
| # Input: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7] | |
| # Output: [3,9,20,null,null,15,7] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/partition-list/ | |
| # 86. Partition List | |
| # Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. | |
| # You should preserve the original relative order of the nodes in each of the two partitions. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/multiply-strings/ | |
| # 43. Multiply String | |
| # Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. | |
| # Note: You must not use any built-in BigInteger library or convert the inputs to integer directly. | |
| # Example 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/swap-nodes-in-pairs/ | |
| # Runtime: 81 ms, faster than 92.68% of Ruby online submissions for Swap Nodes in Pairs. | |
| # Memory Usage: 211.1 MB, less than 18.70% of Ruby online submissions for Swap Nodes in Pairs. | |
| # 24. Swap Nodes in Pairs | |
| # Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://leetcode.com/problems/3sum-closest/ | |
| # 16. 3Sum Closest | |
| # Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. | |
| # Return the sum of the three integers. | |
| # You may assume that each input would have exactly one solution. |
NewerOlder