GoCalf Calf 的自留地 · 昙花一现

<Code author="Calf" />

  • 731. My Calendar II

    #Problem You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking. A triple booking happens when three events have some non-empty intersection (i.e., some moment is …

    medium
  • 581. Shortest Unsorted Continuous Subarray

    #Problem Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order. Return the shortest such subarray …

    medium
  • 2559. Count Vowel Strings in Ranges

    #Problem You are given a 0-indexed array of strings words and a 2D array of integers queries. Each query queries[i] = [lᵢ, rᵢ] asks us to find the number of strings present in the range lᵢ to rᵢ (both inclusive) of words that start and end …

    medium
  • 729. My Calendar I

    #Problem You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking. A double booking happens when two events have some non-empty intersection (i.e., some moment is …

    medium
  • 985. Sum of Even Numbers After Queries

    #Problem You are given an integer array nums and an array queries where queries[i] = [valᵢ, indexᵢ]. For each query i, first, apply nums[indexᵢ] = nums[indexᵢ] + valᵢ, then print the sum of the even values of nums. Return an integer array …

    medium
  • 767. Reorganize String

    #Problem Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return "" if not possible. https://leetcode.com/problems/reorganize-string/ Example 1: …

    medium
  • 1765. Map of Highest Peak

    #Problem You are given an integer matrix isWater of size m x n that represents a map of land and water cells. If isWater[i][j] == 0, cell (i, j) is a land cell. If isWater[i][j] == 1, cell (i, j) is a water cell. You must assign each cell a …

    medium
  • 542. 01 Matrix

    #Problem Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two cells sharing a common edge is 1. https://leetcode.com/problems/01-matrix/ Example 1: case1Input: mat = …

    medium
  • 1029. Two City Scheduling

    #Problem A company is planning to interview 2n people. Given the array costs where costs[i] = [aCostᵢ, bCostᵢ], the cost of flying the iᵗʰ person to city a is aCostᵢ, and the cost of flying the iᵗʰ person to city b is bCostᵢ. Return the …

    medium
  • 1072. Flip Columns For Maximum Number of Equal Rows

    #Problem You are given an m x n binary matrix matrix. You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0 to 1 or vice versa). Return the maximum number of rows …

    medium
  • 382. Linked List Random Node

    #Problem Given a singly linked list, return a random node’s value from the linked list. Each node must have the same probability of being chosen. Implement the Solution class: Solution(ListNode head) Initializes the object with the head of …

    medium
  • 221. Maximal Square

    #Problem Given an m x n binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. https://leetcode.com/problems/maximal-square/ Example 1: case1Input: matrix = …

    medium
  • 1422. Maximum Score After Splitting a String

    #Problem Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring). The score after splitting a string is the number of zeros in the left …

    easy
  • 3280. Convert Date to Binary

    #Problem You are given a string date representing a Gregorian calendar date in the yyyy-mm-dd format. date can be written in its binary representation obtained by converting year, month, and day to their binary representations without any …

    easy
  • 164. Maximum Gap

    #Problem Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0. You must write an algorithm that runs in linear time and uses …

    medium
  • 730. Count Different Palindromic Subsequences

    #Problem Given a string s, return the number of different non-empty palindromic subsequences in s. Since the answer may be very large, return it modulo 10⁹ + 7. A subsequence of a string is obtained by deleting zero or more characters from …

    hard
  • 983. Minimum Cost For Tickets

    #Problem You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array days. Each day is an integer from 1 to 365. Train tickets are sold in three different ways: a …

    medium
  • 913. Cat and Mouse

    #Problem A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns. The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph. The mouse starts at node 1 and goes …

    hard
  • 321. Create Maximum Number

    #Problem You are given two integer arrays nums1 and nums2 of lengths m and n respectively. nums1 and nums2 represent the digits of two numbers. You are also given an integer k. Create the maximum number of length k <= m + n from digits of …

    hard todo
  • 2466. Count Ways To Build Good Strings

    #Problem Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following: Append the character '0' zero times. Append the character '1' one …

    medium
  • 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. …

    medium
  • 843. Guess the Word

    #Problem You are given an array of unique strings words where words[i] is six letters long. One word of words was chosen as a secret word. You are also given the helper object Master. You may call Master.guess(word) where word is a …

    hard
  • 1639. Number of Ways to Form a Target String Given a Dictionary

    #Problem You are given a list of strings of the same length words and a string target. Your task is to form target using the given words under the following rules: target should be formed from left to right. To form the iᵗʰ character …

    hard
  • 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 …

    medium
  • 1206. Design Skiplist

    #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
  • 1250. Check If It Is a Good Array

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

    hard
  • 689. Maximum Sum of 3 Non-Overlapping Subarrays

    #Problem Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with maximum sum and return them. Return the result as a list of indices representing the starting position of each interval …

    hard
  • 3046. Split the Array

    #Problem You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that: nums1.length == nums2.length == nums.length / 2. nums1 should contain distinct elements. nums2 should also …

    easy
  • 2493. Divide Nodes Into the Maximum Number of Groups

    #Problem You are given a positive integer n representing the number of nodes in an undirected graph. The nodes are labeled from 1 to n. You are also given a 2D integer array edges, where edges[i] = [aᵢ, bᵢ] indicates that there is a …

    hard
  • 785. Is Graph Bipartite?

    #Problem There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], …

    medium
  • 1014. Best Sightseeing Pair

    #Problem You are given an integer array values where values[i] represents the value of the iᵗʰ sightseeing spot. Two sightseeing spots i and j have a distance j - i between them. The score of a pair (i < j) of sightseeing spots is values[i] …

    medium