全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
1437. Check If All 1's Are at Least Length K Places Away
#Problem Given an binary array nums and an integer k, return true if all 1’s are at least k places away from each other, otherwise return false. https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away/ Example 1: …
145. Binary Tree Postorder Traversal
#Problem Given the root of a binary tree, return the postorder traversal of its nodes’ values. https://leetcode.com/problems/binary-tree-postorder-traversal/ Example 1: Input: root = [1,null,2,3] Output: [3,2,1] Explanation: case1Example 2: …
1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence
#Problem Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence. Return the index of the word in sentence (1-indexed) where searchWord is a prefix …
1462. Course Schedule IV
#Problem There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [aᵢ, bᵢ] indicates that you must take course aᵢ first if you want to take …
1472. Design Browser History
#Problem You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: …
1475. Final Prices With a Special Discount in a Shop
#Problem You are given an integer array prices where prices[i] is the price of the iᵗʰ item in a shop. There is a special discount for items in the shop. If you buy the iᵗʰ item, then you will receive a discount equivalent to prices[j] …
152. Maximum Product Subarray
#Problem Given an integer array nums, find a subarray that has the largest product, and return the product. A subarray is a contiguous non-empty sequence of elements within an array. The test cases are generated so that the answer will fit …
1524. Number of Sub-arrays With Odd Sum
#Problem Given an array of integers arr, return the number of subarrays with an odd sum. Since the answer can be very large, return it modulo 10⁹ + 7. https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum/ Example 1: Input: arr = …
153. Find Minimum in Rotated Sorted Array
#Problem Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it was rotated 4 times. [0,1,2,4,5,6,7] if it was rotated 7 …