题目: 题解:
class Solution:def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]:res {}stack []for num in reversed(nums2):while stack and num > stack[-1]:stack.pop()res[num] stack[-1] if stack else -1…
题目: 题解:
class Solution:def __init__(self, rects: List[List[int]]):self.rects rectsself.sum [0]for a, b, x, y in rects:self.sum.append(self.sum[-1] (x - a 1) * (y - b 1))def pick(self) -> List[int]:k randrange(self.sum[-1…
题目: 题解:
class Solution {Random rand;List<Integer> arr;int[][] rects;public Solution(int[][] rects) {rand new Random();arr new ArrayList<Integer>();arr.add(0);this.rects rects;for (int[] rect : rects) {int a rect[0…