leetcode再次总结】的更多相关文章

注释 testcases (1)简单一想O(n)算法,有可能通过二分查找变形优化成log(n) (2)双指针:一快一慢 一静一动(数组中最小的长度满足条件,常常用于,确定了一个范围,然后一个指针静止,一个指针收缩) 一前一后 (3)二分查找可以一次性做完,也可以分两次来做,一次用于二分查找左边确定左边界,一次用于二分查找确定右边界. (4)数字理解成二进制的方法,就是通过一个bitvector,简而言之一个32位的数组,循环每一位进行处理. (5)Maximum Subarray 问题,用loc…
Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times. Example 1: Input: s = "aaabb", k = 3 Output: 3 The longest substring is "aaa"…
题目链接:Validate Binary Search Tree | LeetCode OJ 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 nodes with keys less than the node's key. The right…
题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be only one unique solution. A sudoku puzzle... ...and its solution n…
Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one square by using up all those matchsticks. You should not break any stick, but you can link them up, a…
Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays. Note:Given m satisfies the following const…
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins,…
Additive number is a positive integer whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding…
Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty substring in str. Examples: pattern = "abab", str = "redbluer…
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Given nums = [1, 2, 1, 3, 2, 5], return [3, 5]. Note: The order…