GoCalf Calf 的自留地 · 昙花一现

全站内容

Calf

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

  • 1206. Design Skiplist

    Coding

    #Problem Design a Skiplist without using any built-in libraries. A skiplist is a data structure that takes O(log(n)) time to add, erase and search. Comparing with treap and red-black tree which has the same function and performance, the …

    hard
  • 121. Best Time to Buy and Sell Stock

    Coding

    #Problem You are given an array prices where prices[i] is the price of a given stock on the iᵗʰ day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. …

    easy
  • 122. Best Time to Buy and Sell Stock II

    Coding

    #Problem You are given an integer array prices where prices[i] is the price of a given stock on the iᵗʰ day. On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, …

    medium
  • 123. Best Time to Buy and Sell Stock III

    Coding

    #Problem You are given an array prices where prices[i] is the price of a given stock on the iᵗʰ day. Find the maximum profit you can achieve. You may complete at most two transactions. Note: You may not engage in multiple transactions …

    hard
  • 124. Binary Tree Maximum Path Sum

    Coding

    #Problem A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the …

    hard
  • 125. Valid Palindrome

    Coding

    #Problem A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. …

    easy
  • 1250. Check If It Is a Good Array

    Coding

    #Problem Given an array nums of positive integers. Your task is to select some subset of nums, multiply each element by an integer and add all these numbers. The array is said to be good if you can obtain a sum of 1 from the array by any …

    hard
  • 1260. Shift 2D Grid

    Coding

    #Problem Given a 2D grid of size m x n and an integer k. You need to shift the grid k times. In one shift operation: Element at grid[i][j] moves to grid[i][j + 1]. Element at grid[i][n - 1] moves to grid[i + 1][0]. Element at grid[m - 1][n …

    easy
  • 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
  • 1267. Count Servers that Communicate

    Coding

    #Problem You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row …

    medium