阿狸,你怎么这么稳啊,还不出来,赶紧出来吧,爸爸妈妈为你准备好了一切
Category Archives: leetcode
1658. Minimum Operations to Reduce X to Zero
1658. Minimum Operations to Reduce X to Zero Difficulty: Medium Related Topics: Two Pointers, Binary Search, Greedy You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifiesContinueContinue reading “1658. Minimum Operations to Reduce X to Zero”
1657. Determine if Two Strings Are Close
1657. Determine if Two Strings Are Close Difficulty: Medium Related Topics: Greedy Two strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters.For example, a<u style=”display: inline;”>b</u>cd<u style=”display: inline;”>e</u> -> a<u style=”display: inline;”>e</u>cd<u style=”display: inline;”>b</u>Operation 2: Transform every occurrence of one existingContinueContinue reading “1657. Determine if Two Strings Are Close”
1656. Design an Ordered Stream
1656. Design an Ordered Stream Difficulty: Easy Related Topics: Array, Design There are n (id, value) pairs, where id is an integer between 1 and n and value is a string. No two pairs have the same id. Design a stream that takes the n pairs in an arbitrary order, and returns the values overContinueContinue reading “1656. Design an Ordered Stream”
841. Keys and Rooms
841. Keys and Rooms Difficulty: Medium Related Topics: Depth-first Search, Graph There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, …, N-1, and each room may have some keys to access the next room. Formally, each room i has a list of keys rooms[i], and eachContinueContinue reading “841. Keys and Rooms”
951. Flip Equivalent Binary Trees
951. Flip Equivalent Binary Trees Difficulty: Medium Related Topics: Tree For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees. A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal toContinueContinue reading “951. Flip Equivalent Binary Trees”
998. Maximum Binary Tree II
998. Maximum Binary Tree II Difficulty: Medium Related Topics: Tree We are given the root node of a maximum tree: a tree where every node has a value greater than any other value in its subtree. Just as in the , the given tree was constructed from an list A (root = Construct(A)) recursively with the following Construct(A) routine: IfContinueContinue reading “998. Maximum Binary Tree II”
713. Subarray Product Less Than K
713. Subarray Product Less Than K Difficulty: Medium Related Topics: Array, Two Pointers Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k. Example 1: Input: nums = [10, 5, 2, 6], k =ContinueContinue reading “713. Subarray Product Less Than K”
611. Valid Triangle Number
611. Valid Triangle Number Difficulty: Medium Related Topics: Array Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: Input: [2,2,3,4] Output: 3 Explanation: Valid combinations are: 2,3,4 (usingContinueContinue reading “611. Valid Triangle Number”
560. Subarray Sum Equals K
560. Subarray Sum Equals K Difficulty: Medium Related Topics: Array, Hash Table Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Constraints: The length of the array is in rangeContinueContinue reading “560. Subarray Sum Equals K”