随笔分类 - 算法
本分类用于存放一些算法题,主要来源于Leetcode。
摘要:题目 Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from
阅读全文
摘要:题目 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
阅读全文
摘要:题目 An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the s
阅读全文
摘要:题目 An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the s
阅读全文
摘要:题目 Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid ans
阅读全文
摘要:题目 There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-
阅读全文
摘要:题目 Given an array of non-negative integers nums, you are initially positioned at the first index of the array. Each element in the array represents yo
阅读全文
摘要:题目 You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum
阅读全文
摘要:题目 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are
阅读全文
摘要:题目 Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequ
阅读全文
摘要:题目 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","
阅读全文
摘要:题目 Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate n
阅读全文
摘要:题目 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in
阅读全文
摘要:题目 Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen
阅读全文
摘要:题目 Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. Example 1: Input: nums =
阅读全文
摘要:题目 Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate s
阅读全文
摘要:题目 Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. R
阅读全文
摘要:题目 Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any o
阅读全文
摘要:题目 Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'. A region is captured by flippin
阅读全文
摘要:题目 Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix. If there is no clear path, return -1. A clear path i
阅读全文