02 2019 档案

摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Example 2: 题意 给出s1,s2,s3,判断是否能从s3中抽取出若干个字符以原顺序组成字符串和s1相等,并且s3 阅读全文
posted @ 2019-02-27 20:15 TobicYAL 阅读(164) 评论(0) 推荐(0) 编辑
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: 1 class Solution { 2 public: 3 vector<int>q; 4 i 阅读全文
posted @ 2019-02-27 18:22 TobicYAL 阅读(225) 评论(0) 推荐(0) 编辑
摘要:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n. Example: 题意 给定一数n,求1-n所组成的所有可能的BST树的集合 题解 阅读全文
posted @ 2019-02-24 22:08 TobicYAL 阅读(196) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return the inorder traversal of its nodes' values. Example: 1 class Solution { 2 public: 3 void build(TreeNode*root, vector<int>& 阅读全文
posted @ 2019-02-24 21:39 TobicYAL 阅读(123) 评论(0) 推荐(0) 编辑
摘要:Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: 1 class Solution { 2 public: 3 ListNode* rev 阅读全文
posted @ 2019-02-24 21:29 TobicYAL 阅读(136) 评论(0) 推荐(0) 编辑
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given a non-empty string containing only digits, determ 阅读全文
posted @ 2019-02-23 19:16 TobicYAL 阅读(170) 评论(0) 推荐(0) 编辑
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta 阅读全文
posted @ 2019-02-23 17:01 TobicYAL 阅读(118) 评论(0) 推荐(0) 编辑
摘要:The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total num 阅读全文
posted @ 2019-02-23 13:50 TobicYAL 阅读(202) 评论(0) 推荐(0) 编辑
摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representati 阅读全文
posted @ 2019-02-23 10:57 TobicYAL 阅读(201) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2019-02-23 09:37 TobicYAL 阅读(158) 评论(0) 推荐(0) 编辑
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example: 题意 找图中由1组成的最大矩形 题解 1 cl 阅读全文
posted @ 2019-02-23 09:20 TobicYAL 阅读(178) 评论(0) 推荐(0) 编辑
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文
posted @ 2019-02-22 21:32 TobicYAL 阅读(236) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Example 2: 阅读全文
posted @ 2019-02-21 19:58 TobicYAL 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). Y 阅读全文
posted @ 2019-02-19 09:28 TobicYAL 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra 阅读全文
posted @ 2019-02-15 17:49 TobicYAL 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文
posted @ 2019-02-15 17:20 TobicYAL 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl 阅读全文
posted @ 2019-02-15 16:13 TobicYAL 阅读(132) 评论(0) 推荐(0) 编辑
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: 题意 在1到n中取k个数的所有情况 题解 1 class Solution { 2 public: 3 阅读全文
posted @ 2019-02-15 15:45 TobicYAL 阅读(118) 评论(0) 推荐(0) 编辑
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Note: If there i 阅读全文
posted @ 2019-02-15 15:16 TobicYAL 阅读(122) 评论(0) 推荐(0) 编辑
摘要:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or 阅读全文
posted @ 2019-02-13 20:41 TobicYAL 阅读(133) 评论(0) 推荐(0) 编辑
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文
posted @ 2019-02-13 20:13 TobicYAL 阅读(122) 评论(0) 推荐(0) 编辑
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Example 2: Follow up: A straight forward solu 阅读全文
posted @ 2019-02-13 20:04 TobicYAL 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文
posted @ 2019-02-13 19:40 TobicYAL 阅读(147) 评论(0) 推荐(0) 编辑
摘要:Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path. In a UNIX-style file system, a perio 阅读全文
posted @ 2019-02-13 18:23 TobicYAL 阅读(175) 评论(0) 推荐(0) 编辑
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2019-02-12 22:11 TobicYAL 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an in 阅读全文
posted @ 2019-02-12 22:04 TobicYAL 阅读(279) 评论(0) 推荐(0) 编辑
摘要:Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justif 阅读全文
posted @ 2019-02-12 21:46 TobicYAL 阅读(160) 评论(0) 推荐(0) 编辑
摘要:Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. Example 1 阅读全文
posted @ 2019-02-12 20:02 TobicYAL 阅读(141) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant d 阅读全文
posted @ 2019-02-12 17:39 TobicYAL 阅读(166) 评论(0) 推荐(0) 编辑
摘要: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. 阅读全文
posted @ 2019-02-11 11:14 TobicYAL 阅读(179) 评论(0) 推荐(0) 编辑
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-02-11 10:43 TobicYAL 阅读(172) 评论(0) 推荐(0) 编辑
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-02-09 16:31 TobicYAL 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Example 2: 题意 把链表循环右移k个 题解 1 class Solution { 2 pub 阅读全文
posted @ 2019-02-09 16:21 TobicYAL 阅读(173) 评论(0) 推荐(0) 编辑
摘要:The set [1,2,3,...,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following seque 阅读全文
posted @ 2019-02-09 16:09 TobicYAL 阅读(233) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. Example: 1 class Solution { 2 public: 3 vector 阅读全文
posted @ 2019-02-09 15:41 TobicYAL 阅读(388) 评论(0) 推荐(0) 编辑
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word 阅读全文
posted @ 2019-02-09 15:29 TobicYAL 阅读(157) 评论(0) 推荐(0) 编辑
摘要:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文
posted @ 2019-02-09 15:20 TobicYAL 阅读(157) 评论(0) 推荐(0) 编辑
摘要:Given a collection of intervals, merge all overlapping intervals. Example 1: Example 2: 题意 合并重合的闭区间 题解 1 bool operator <(const Interval& a, const Inte 阅读全文
posted @ 2019-02-08 19:34 TobicYAL 阅读(129) 评论(0) 推荐(0) 编辑
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2019-02-08 17:47 TobicYAL 阅读(147) 评论(0) 推荐(0) 编辑
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Example 2: 题意 顺时针螺旋输出数组 题解 1 class 阅读全文
posted @ 2019-02-08 17:37 TobicYAL 阅读(190) 评论(0) 推荐(0) 编辑
摘要:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Foll 阅读全文
posted @ 2019-02-08 17:08 TobicYAL 阅读(139) 评论(0) 推荐(0) 编辑
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the 阅读全文
posted @ 2019-02-08 16:32 TobicYAL 阅读(177) 评论(0) 推荐(0) 编辑
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all 阅读全文
posted @ 2019-02-08 16:25 TobicYAL 阅读(251) 评论(0) 推荐(0) 编辑
摘要:Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Example 2: Example 3: Note: -100.0 < x < 100.0 n is a 32-bit signed int 阅读全文
posted @ 2019-02-07 20:26 TobicYAL 阅读(178) 评论(0) 推荐(0) 编辑
摘要:Given an array of strings, group anagrams together. Example: 题意 把由相同字母出现相同次数组成的字符串归到一起(数据可能重复) 题解 一开始我当成了任何一种字母只会出现一次做了,用的是long型作二进制用,自然WA了,其实后来可以用字符串 阅读全文
posted @ 2019-02-07 19:17 TobicYAL 阅读(148) 评论(0) 推荐(0) 编辑
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which 阅读全文
posted @ 2019-02-07 18:28 TobicYAL 阅读(167) 评论(0) 推荐(0) 编辑
摘要:Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example: 1 class Solution { 2 public: 3 vector<v 阅读全文
posted @ 2019-02-07 17:36 TobicYAL 阅读(150) 评论(0) 推荐(0) 编辑
摘要:Given a collection of distinct integers, return all possible permutations. Example: 1 class Solution { 2 public: 3 void build(vector<bool>visited, vec 阅读全文
posted @ 2019-02-07 17:33 TobicYAL 阅读(145) 评论(0) 推荐(0) 编辑
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2019-02-07 17:02 TobicYAL 阅读(257) 评论(0) 推荐(0) 编辑
摘要:Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. The matching should cover the entire in 阅读全文
posted @ 2019-02-04 14:55 TobicYAL 阅读(224) 评论(0) 推荐(0) 编辑
摘要:Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Example 1: Ex 阅读全文
posted @ 2019-02-04 14:25 TobicYAL 阅读(162) 评论(0) 推荐(0) 编辑
摘要: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. 阅读全文
posted @ 2019-02-04 14:07 TobicYAL 阅读(166) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted integer array, find the smallest missing positive integer. Example 1: Example 2: Example 3: Note: Your algorithm should run in O(n) 阅读全文
posted @ 2019-02-04 11:01 TobicYAL 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numb 阅读全文
posted @ 2019-02-03 22:28 TobicYAL 阅读(236) 评论(0) 推荐(0) 编辑
摘要:Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the 阅读全文
posted @ 2019-02-03 17:16 TobicYAL 阅读(139) 评论(0) 推荐(0) 编辑
摘要:The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is read off as "two 1 阅读全文
posted @ 2019-02-03 16:40 TobicYAL 阅读(132) 评论(0) 推荐(0) 编辑
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Empty cells are indica 阅读全文
posted @ 2019-02-03 15:32 TobicYAL 阅读(195) 评论(0) 推荐(0) 编辑
摘要:Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: A partially filled sudoku which 阅读全文
posted @ 2019-02-03 14:08 TobicYAL 阅读(184) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2019-02-03 11:47 TobicYAL 阅读(130) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime com 阅读全文
posted @ 2019-02-02 22:54 TobicYAL 阅读(125) 评论(0) 推荐(0) 编辑
摘要: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]). Y 阅读全文
posted @ 2019-02-02 22:14 TobicYAL 阅读(119) 评论(0) 推荐(0) 编辑
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Exampl 阅读全文
posted @ 2019-02-01 19:05 TobicYAL 阅读(132) 评论(0) 推荐(0) 编辑
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2019-02-01 14:07 TobicYAL 阅读(133) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示