11 2022 档案
摘要:Given an integer array nums, return the length of the longest strictly increasing subsequence. Example 1: Input: nums = [10,9,2,5,3,7,101,18] Output:
阅读全文
摘要:剑指offer https://www.cnblogs.com/MarkLeeBYR/p/9773495.html
阅读全文
摘要:剑指offer 数组中的重复数字 https://www.cnblogs.com/MarkLeeBYR/p/9773954.html
阅读全文
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, giv
阅读全文
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12,
阅读全文
摘要:剑指offer 二维数组的查找 https://www.cnblogs.com/MarkLeeBYR/p/9777341.html
阅读全文
摘要:剑指offer 构建乘积数组 https://www.cnblogs.com/MarkLeeBYR/p/9773723.html
阅读全文
摘要:给定一个二叉树和所要查找的两个节点,找到两个节点的最近公共父亲节点(LCA)。比如,节点5和1的LCA是3,节点5和4的LCA是5。 class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, Tr
阅读全文
摘要:Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false public boolean isPalindrome(ListNode head) { ListNode mid
阅读全文
摘要:剑指offer 二叉搜索树的第k个节点 https://www.cnblogs.com/MarkLeeBYR/p/9773509.html
阅读全文
摘要:剑指offer https://www.cnblogs.com/MarkLeeBYR/p/9776556.html
阅读全文
摘要:参考剑指offer 最小的k个数字 https://www.cnblogs.com/MarkLeeBYR/p/9775091.html
阅读全文
摘要:Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs are consist of lowercase letters a-z. class TrieNode
阅读全文
摘要:剑指offer 反转链表 https://www.cnblogs.com/MarkLeeBYR/p/9773053.html
阅读全文
摘要:Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by wa
阅读全文
摘要:Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bot
阅读全文
摘要:给定一个整数数组Arr,求解数组中连续的不相邻元素的和的最大值。例如:对于数组中的元素A1,A2,A3,A4,则需要判断A1+A3,A1+A4,A2+A4中的最大值即为所求。 状态转移方程:dp[i] = max(dp[i - 2], dp[i - 3]) + num[i] 其中,dp[i]表示打劫
阅读全文
摘要:Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Not
阅读全文
摘要:剑指offer 数组中出现超过一半的数字 https://www.cnblogs.com/MarkLeeBYR/p/9775097.html
阅读全文
摘要:剑指offer 两个链表公共节点 https://www.cnblogs.com/MarkLeeBYR/p/9774276.html
阅读全文
摘要:剑指offer 旋转数组的最小值 https://www.cnblogs.com/MarkLeeBYR/p/9777244.html
阅读全文
摘要:Given an integer array nums, find a subarray that has the largest product, and return the product. The test cases are generated so that the answer wil
阅读全文
摘要:Sort a linked list in O(n log n) time using constant space complexity. //利用归并排序的思想 public ListNode sortList(ListNode head) { if (head == null || head.
阅读全文
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the
阅读全文
摘要:剑指offer 链表环入口 https://www.cnblogs.com/MarkLeeBYR/p/9773649.html
阅读全文
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequ
阅读全文
摘要:剑指offer 复杂链表的复制 https://www.cnblogs.com/MarkLeeBYR/p/9775184.html
阅读全文
摘要:Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linea
阅读全文
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Example 1:
阅读全文
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The longes
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction
阅读全文
摘要:iven numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return : [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]
阅读全文
摘要:/例如根节点为1,左2右3 class Solution { TreeNode prev = null; public void flatten(TreeNode root) {//先把最大的数设在root.right,然后剩下的数一个个往里加 if (root == null) return; f
阅读全文
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. public TreeNode sortedArrayToBST(int[] nums) { if (n
阅读全文
摘要:见剑指offer重建二叉树 https://www.cnblogs.com/MarkLeeBYR/p/9777253.html
阅读全文
摘要:Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l
阅读全文
摘要:Solution 1: class Solution { public List<List<Integer>> levelOrder(TreeNode root) { Queue<TreeNode> queue = new LinkedList<>(); List<List<Integer>> wr
阅读全文
摘要:Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only
阅读全文
摘要://Solution 1:递归 public List<Integer> inorderTraversal(TreeNode root) { List<Integer> list =new ArrayList<>(); addNode(list, root); return list;}privat
阅读全文
摘要:Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle
阅读全文
摘要:给你一个字符串 s 、一个字符串 t 。返回 s 中涵盖 t 所有字符的最小子串。如果 s 中不存在涵盖 t 所有字符的子串,则返回空字符串 输入:s = "ADOBECODEBANC", t = "ABC"输出:"BANC"解释:最小覆盖子串 "BANC" 包含来自字符串 t 的 'A'、'B'
阅读全文
摘要:剑指offer 矩阵中的路径 https://www.cnblogs.com/MarkLeeBYR/p/9773357.html
阅读全文
摘要:样例输入{1,8,5,4} 输出 [[], [1], [1, 4], [1, 4, 5], [1, 4, 5, 8], [1, 4, 8], [1, 5], [1, 5, 8], [1, 8], [4], [4, 5], [4, 5, 8], [4, 8], [5], [5, 8], [8]] 注意
阅读全文
摘要:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red,
阅读全文
摘要:剑指offer 二维数组中的查找 https://www.cnblogs.com/MarkLeeBYR/p/9777341.html
阅读全文
摘要:iven a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. //如果某个元素为0,则把该元素所在的行和列都设为0。本题用了o
阅读全文
摘要:Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations
阅读全文
摘要:剑指offer 跳台阶 https://www.cnblogs.com/MarkLeeBYR/p/9777214.html
阅读全文
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
阅读全文
摘要: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-rig
阅读全文
摘要:Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals
阅读全文
摘要:剑指offer 顺时针打印矩阵 https://www.cnblogs.com/MarkLeeBYR/p/9776471.html
阅读全文
摘要:看剑指offer 连续子数组的最大和 https://www.cnblogs.com/MarkLeeBYR/p/9774387.html
阅读全文
摘要: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 al
阅读全文
摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: [ ["ate", "eat","tea"], ["
阅读全文
摘要: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
阅读全文
摘要:Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,
阅读全文
摘要:You are given a 0-indexed array of integers nums of length n. You are initially positioned at nums[0]. Each element nums[i] represents the maximum len
阅读全文
摘要: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 ju
阅读全文
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
阅读全文
摘要:Given an unsorted integer array, find the smallest missing positive integer. Example 1: Input: [1,2,0]Output: 3Example 2: Input: [3,4,-1,1]Output: 2Ex
阅读全文
摘要:Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums
阅读全文
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or
阅读全文
摘要:剑指offer:数字在排序数组中出现的次数 https://www.cnblogs.com/MarkLeeBYR/p/9774275.html
阅读全文
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You a
阅读全文
摘要:Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring. Example 1: Inpu
阅读全文
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib
阅读全文
摘要:Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list. 本题我们可以借助一个Stack来解题。我们从链表头部开始,向Stack中插入k个节点,然
阅读全文
摘要:Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your a
阅读全文
摘要: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
阅读全文
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [
阅读全文
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. public L
阅读全文
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the
阅读全文
摘要:Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After rem
阅读全文
摘要:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of
阅读全文
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo
阅读全文