GoCalf Calf 的自留地 · 昙花一现

全站内容

medium

  • 2353. Design a Food Rating System

    Coding

    #Problem Design a food rating system that can do the following: Modify the rating of a food item listed in the system. Return the highest-rated food item for a type of cuisine in the system. Implement the FoodRatings class: …

    medium
  • 873. Length of Longest Fibonacci Subsequence

    Coding

    #Problem A sequence x₁, x₂, ..., xₙ is Fibonacci-like if: n >= 3 xᵢ + xᵢ₊₁ == xᵢ₊₂ for all i + 2 <= n Given a strictly increasing array arr of positive integers forming a sequence, return the length of the longest Fibonacci-like subsequence …

    medium
  • 1524. Number of Sub-arrays With Odd Sum

    Coding

    #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 = …

    medium
  • 1749. Maximum Absolute Sum of Any Subarray

    Coding

    #Problem You are given an integer array nums. The absolute sum of a subarray [numsₗ, numsₗ₊₁, ..., numsᵣ₋₁, numsᵣ] is abs(numsₗ + numsₗ₊₁ + ... + numsᵣ₋₁ + numsᵣ). Return the maximum absolute sum of any (possibly empty) subarray of nums. …

    medium
  • 1472. Design Browser History

    Coding

    #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: …

    medium
  • 2502. Design Memory Allocator

    Coding

    #Problem You are given an integer n representing the size of a 0-indexed memory array. All memory units are initially free. You have a memory allocator with the following functionalities: Allocate a block of size consecutive free memory …

    medium
  • 2467. Most Profitable Path in a Tree

    Coding

    #Problem There is an undirected tree with n nodes labeled from 0 to n - 1, rooted at node 0. You are given a 2D integer array edges of length n - 1 where edges[i] = [aᵢ, bᵢ] indicates that there is an edge between nodes aᵢ and bᵢ in the …

    medium
  • 889. Construct Binary Tree from Preorder and Postorder Traversal

    Coding

    #Problem Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the postorder traversal of the same tree, reconstruct and return the binary tree. If …

    medium
  • 1261. Find Elements in a Contaminated Binary Tree

    Coding

    #Problem Given a binary tree with the following rules: root.val == 0 For any treeNode: If treeNode.val has a value x and treeNode.left != null, then treeNode.left.val == 2 * x + 1 If treeNode.val has a value x and treeNode.right != null, …

    medium
  • 1980. Find Unique Binary String

    Coding

    #Problem Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you may return any of them. …

    medium