全站内容
Calf
这里收录 Calf 在 GoCalf 上的文章、笔记与其他内容。
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 …
494. Target Sum
#Problem You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers. For example, if nums …
496. Next Greater Element I
#Problem The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2. …
5. Longest Palindromic Substring
#Problem Given a string s, return the longest palindromic substring in s. A string is palindromic if it reads the same forward and backward. A substring is a contiguous non-empty sequence of characters within a string. …
50. Pow(x, n)
#Problem Implement pow(x, n), which calculates x raised to the power n (i.e., xⁿ). https://leetcode.com/problems/powx-n/ Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example …
503. Next Greater Element II
#Problem Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums. The next greater number of a number x is the first greater number to its …
51. N-Queens
#Problem The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any …
515. Find Largest Value in Each Tree Row
#Problem Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). https://leetcode.com/problems/find-largest-value-in-each-tree-row/ Example 1: case1Input: root = [1,3,2,5,3,null,9] Output: …
52. N-Queens II
#Problem The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return the number of distinct solutions to the n-queens puzzle. …
53. Maximum Subarray
#Problem Given an integer array nums, find the subarray with the largest sum, and return its sum. A subarray is a contiguous non-empty sequence of elements within an array. https://leetcode.com/problems/maximum-subarray/ Example 1: Input: …