GoCalf Calf 的自留地 · 昙花一现

全站内容

Calf

这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。

  • 235. Lowest Common Ancestor of a Binary Search Tree

    Coding

    #Problem Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the …

    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
  • 2360. Longest Cycle in a Graph

    Coding

    #Problem You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge. The graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from …

    hard
  • 2364. Count Number of Bad Pairs

    Coding

    #Problem You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i < j and j - i != nums[j] - nums[i]. Return the total number of bad pairs in nums. https://leetcode.com/problems/count-number-of-bad-pairs/ …

    medium
  • 2375. Construct Smallest Number From DI String

    Coding

    #Problem You are given a 0-indexed string pattern of length n consisting of the characters 'I' meaning increasing and 'D' meaning decreasing. A 0-indexed string num of length n + 1 is created using the following conditions: num consists of …

    medium
  • 238. Product of Array Except Self

    Coding

    #Problem Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You …

    medium
  • 2381. Shifting Letters II

    Coding

    #Problem You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [startᵢ, endᵢ, directionᵢ]. For every i, shift the characters in s from the index startᵢ to the index endᵢ (inclusive) forward if …

    medium
  • 2412. Minimum Money Required Before Transactions

    Coding

    #Problem You are given a 0-indexed 2D integer array transactions, where transactions[i] = [costᵢ, cashbackᵢ]. The array describes transactions, where each transaction must be completed exactly once in some order. At any given moment, you …

    hard
  • 2415. Reverse Odd Levels of Binary Tree

    Coding

    #Problem Given the root of a perfect binary tree, reverse the node values at each odd level of the tree. For example, suppose the node values at level 3 are [2,1,3,4,7,11,29,18], then it should become [18,29,11,7,4,3,1,2]. Return the root …

    medium
  • 242. Valid Anagram

    Coding

    #Problem Given two strings s and t, return true if t is an anagram of s, and false otherwise. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once. …

    easy