全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
128. Longest Consecutive Sequence
#Problem Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. https://leetcode.com/problems/longest-consecutive-sequence/ Example 1: …
1287. Element Appearing More Than 25% In Sorted Array
#Problem Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer. …
1298. Maximum Candies You Can Get from Boxes
#Problem You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where: status[i] is 1 if the iᵗʰ box is open and 0 if the iᵗʰ box is closed, candies[i] is the number of candies in the …
1299. Replace Elements with Greatest Element on Right Side
#Problem Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. …
133. Clone Graph
#Problem Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors. c++ 复制 class Node { public int val; …
1338. Reduce Array Size to The Half
#Problem You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at least half of the integers of the array are removed. …
1346. Check If N and Its Double Exist
#Problem Given an array arr of integers, check if there exist two indices i and j such that : i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] https://leetcode.com/problems/check-if-n-and-its-double-exist/ Example 1: Input: arr = …
1352. Product of the Last K Numbers
#Problem Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream. Implement the ProductOfNumbers class: ProductOfNumbers() Initializes the object with an empty stream. void …
1366. Rank Teams by Votes
#Problem In a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition. The ordering of teams is decided by who received the most position-one votes. If two or more teams tie in …
1367. Linked List in Binary Tree
#Problem Given a binary tree root and a linked list with head as the first node. Return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False. …