GoCalf Calf 的自留地 · 昙花一现

<Code author="Calf" />

  • 54. Spiral Matrix

    #Problem Given an m x n matrix, return all elements of the matrix in spiral order. https://leetcode.com/problems/spiral-matrix/ Example 1: case1Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,4,5] Example 2: case2Input: …

    medium
  • 661. Image Smoother

    #Problem An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nine cells in the blue smoother). If …

    easy
  • 435. Non-overlapping Intervals

    #Problem Given an array of intervals intervals where intervals[i] = [startᵢ, endᵢ], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note that intervals which only touch at a point …

    medium
  • 49. Group Anagrams

    #Problem Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters …

    medium
  • 48. Rotate Image

    #Problem You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D …

    medium
  • 300. Longest Increasing Subsequence

    #Problem Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the …

    medium hard
  • 825. Friends Of Appropriate Ages

    #Problem There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the iᵗʰ person. A Person x will not send a friend request to a person y (x != y) if any of the following conditions is …

    medium
  • 297. Serialize and Deserialize Binary Tree

    #Problem Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the …

    hard
  • 424. Longest Repeating Character Replacement

    #Problem You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times. Return the length of the longest …

    medium
  • 295. Find Median from Data Stream

    #Problem The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values. For example, for arr = [2,3,4], the median is 3. For …

    hard
  • 3240. Minimum Number of Flips to Make Binary Grid Palindromic II

    #Problem You are given an m x n binary matrix grid. A row or column is considered palindromic if its values read the same forward and backward. You can flip any number of cells in grid from 0 to 1, or from 1 to 0. Return the minimum number …

    medium
  • 417. Pacific Atlantic Water Flow

    #Problem There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island’s left and top edges, and the Atlantic Ocean touches the island’s right and bottom edges. The island …

    medium
  • 33. Search in Rotated Sorted Array

    #Problem There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length) such that the resulting array is …

    medium
  • 153. Find Minimum in Rotated Sorted Array

    #Problem Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it was rotated 4 times. [0,1,2,4,5,6,7] if it was rotated 7 …

    medium
  • 3239. Minimum Number of Flips to Make Binary Grid Palindromic I

    #Problem You are given an m x n binary matrix grid. A row or column is considered palindromic if its values read the same forward and backward. You can flip any number of cells in grid from 0 to 1, or from 1 to 0. Return the minimum number …

    medium
  • 152. Maximum Product Subarray

    #Problem Given an integer array nums, find a subarray that has the largest product, and return the product. A subarray is a contiguous non-empty sequence of elements within an array. The test cases are generated so that the answer will fit …

    medium
  • 23. Merge k Sorted Lists

    #Problem You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. https://leetcode.com/problems/merge-k-sorted-lists/ Example 1: …

    hard
  • 21. Merge Two Sorted Lists

    #Problem You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. …

    easy
  • 20. Valid Parentheses

    #Problem Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be …

    easy
  • 19. Remove Nth Node From End of List

    #Problem Given the head of a linked list, remove the nᵗʰ node from the end of the list and return its head. https://leetcode.com/problems/remove-nth-node-from-end-of-list/ Example 1: case1Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] …

    medium
  • 143. Reorder List

    #Problem You are given the head of a singly linked-list. The list can be represented as: L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form: L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → … You may not modify the values in the …

    medium
  • 3249. Count the Number of Good Nodes

    #Problem There is an undirected tree with n nodes labeled from 0 to n - 1, and 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 …

    medium
  • 3261. Count Substrings That Satisfy K-Constraint II

    #Problem You are given a binary string s and an integer k. You are also given a 2D integer array queries, where queries[i] = [lᵢ, rᵢ]. A binary string satisfies the k-constraint if either of the following conditions holds: The number of 0’s …

    hard
  • 15. 3Sum

    #Problem Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. …

    medium
  • 268. Missing Number

    #Problem Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. https://leetcode.com/problems/missing-number/ Example 1: Input: nums = [3,0,1] Output: 2 …

    easy
  • 141. Linked List Cycle

    #Problem Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. …

    easy
  • 3258. Count Substrings That Satisfy K-Constraint I

    #Problem You are given a binary string s and an integer k. A binary string satisfies the k-constraint if either of the following conditions holds: The number of 0’s in the string is at most k. The number of 1’s in the string is at most k. …

    easy
  • 139. Word Break

    #Problem Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the …

    medium
  • 1547. Minimum Cost to Cut a Stick

    #Problem Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows: stickGiven an integer array cuts where cuts[i] denotes a position you should perform a cut at. You …

    hard
  • 11. Container With Most Water

    #Problem You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that …

    medium
  • 647. Palindromic Substrings

    #Problem Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string. …

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

    medium