08 2018 档案

摘要:一道题根本不会,抄答案过了。一道自己写,莫名其妙出现了不会的bug。最后交了暴力解,过了5/7。估计要跪。 总结: 缺点:做过的不熟练。没做过的题不会。一个陌生的小bug也de不出来。 措施:多总结还是有好处的。坚持刷tag题有必要,绝对能慢慢增强实力,很重要。 指定方向的dp: 改变i - 1 j 阅读全文
posted @ 2018-08-31 23:22 苗妙苗 阅读(1478) 评论(0) 推荐(0)
摘要:[抄题]: Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like 阅读全文
posted @ 2018-08-28 20:46 苗妙苗 阅读(400) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The 阅读全文
posted @ 2018-08-28 04:33 苗妙苗 阅读(529) 评论(0) 推荐(0)
摘要:[抄题]: We have some permutation A of [0, 1, ..., N - 1], where N is the length of A. The number of (global) inversions is the number of i < j with 0 <= 阅读全文
posted @ 2018-08-28 04:19 苗妙苗 阅读(227) 评论(0) 推荐(0)
摘要:[抄题]: Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer 阅读全文
posted @ 2018-08-27 08:07 苗妙苗 阅读(328) 评论(0) 推荐(0)
摘要:[抄题]: Given a Binary Search Tree (BST) with root node root, and a target value V, split the tree into two subtrees where one subtree has nodes that ar 阅读全文
posted @ 2018-08-24 09:35 苗妙苗 阅读(753) 评论(0) 推荐(0)
摘要:[抄题]: Imagine you have a special keyboard with the following keys: Key 1: (A): Print one 'A' on screen. Key 2: (Ctrl-A): Select the whole screen. Key 阅读全文
posted @ 2018-08-24 06:26 苗妙苗 阅读(240) 评论(0) 推荐(0)
摘要:[抄题]: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element f 阅读全文
posted @ 2018-08-24 04:31 苗妙苗 阅读(158) 评论(0) 推荐(0)
摘要:[抄题]: In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successo 阅读全文
posted @ 2018-08-24 02:37 苗妙苗 阅读(281) 评论(0) 推荐(0)
摘要:[抄题]: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For ex 阅读全文
posted @ 2018-08-23 22:40 苗妙苗 阅读(191) 评论(0) 推荐(0)
摘要:[抄题]: 简而言之:只能对 杯子中全部的水/容量-杯子中全部的水进行操作 You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. Yo 阅读全文
posted @ 2018-08-23 10:40 苗妙苗 阅读(281) 评论(0) 推荐(0)
摘要:[抄题]: There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of t 阅读全文
posted @ 2018-08-23 09:04 苗妙苗 阅读(162) 评论(0) 推荐(0)
摘要:[抄题]: Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Given a number n. You ha 阅读全文
posted @ 2018-08-23 05:42 苗妙苗 阅读(136) 评论(0) 推荐(0)
摘要:[抄题]: Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the 阅读全文
posted @ 2018-08-23 04:39 苗妙苗 阅读(254) 评论(0) 推荐(0)
摘要:[抄题]: Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) 阅读全文
posted @ 2018-08-22 22:11 苗妙苗 阅读(387) 评论(0) 推荐(0)
摘要:[抄题]: Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in p 阅读全文
posted @ 2018-08-22 21:17 苗妙苗 阅读(664) 评论(0) 推荐(0)
摘要:[抄题]: Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but ma 阅读全文
posted @ 2018-08-22 11:33 苗妙苗 阅读(182) 评论(0) 推荐(0)
摘要:[抄题]: Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: Example: [暴力解法]: 时间分析: 空间分析: [ 阅读全文
posted @ 2018-08-22 05:54 苗妙苗 阅读(388) 评论(0) 推荐(0)
摘要:[抄题]: 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 阅读全文
posted @ 2018-08-22 04:03 苗妙苗 阅读(149) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. 阅读全文
posted @ 2018-08-21 23:08 苗妙苗 阅读(137) 评论(0) 推荐(0)
摘要:[抄题]: Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and 阅读全文
posted @ 2018-08-21 21:50 苗妙苗 阅读(304) 评论(0) 推荐(0)
摘要:[抄题]: We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the 阅读全文
posted @ 2018-08-21 10:37 苗妙苗 阅读(254) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in i 阅读全文
posted @ 2018-08-20 05:18 苗妙苗 阅读(321) 评论(0) 推荐(0)
摘要:[抄题]: Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Example 1: Input 阅读全文
posted @ 2018-08-13 21:02 苗妙苗 阅读(291) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition num 阅读全文
posted @ 2018-08-12 21:55 苗妙苗 阅读(156) 评论(0) 推荐(0)
摘要:[抄题]: Given two 1d vectors, implement an iterator to return their elements alternately. Example: Follow up: What if you are given k 1d vectors? How we 阅读全文
posted @ 2018-08-12 18:04 苗妙苗 阅读(263) 评论(0) 推荐(0)
摘要:[抄题]: Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increas 阅读全文
posted @ 2018-08-12 14:40 苗妙苗 阅读(172) 评论(0) 推荐(0)
摘要:[抄题]: Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: 阅读全文
posted @ 2018-08-12 09:37 苗妙苗 阅读(180) 评论(0) 推荐(0)
摘要:1. 分解问题的角度: fix 某一维度,尝试另一维度上的所有可能 a. 可能是array的(i, j)pointers, b. 可能是矩形的长与宽, c. 可能是tree的每一个subtree, d. 可能是情景题的每一对pair...2. 求所有解的, 暴力上backtracking吧3. 如果 阅读全文
posted @ 2018-08-12 09:23 苗妙苗 阅读(317) 评论(0) 推荐(0)
摘要:[抄题]: Given a sorted array of integers nums and integer values a, b and c. Apply a quadratic function of the form f(x) = ax2 + bx + c to each element  阅读全文
posted @ 2018-08-11 23:30 苗妙苗 阅读(170) 评论(0) 推荐(0)
摘要:[抄题]: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that 阅读全文
posted @ 2018-08-11 17:36 苗妙苗 阅读(292) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2-> 阅读全文
posted @ 2018-08-11 17:01 苗妙苗 阅读(282) 评论(0) 推荐(0)
摘要:[抄题]: On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly Kmoves. The rows and columns are 0 indexed, s 阅读全文
posted @ 2018-08-11 15:38 苗妙苗 阅读(321) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: [暴力解法]: 阅读全文
posted @ 2018-08-11 10:14 苗妙苗 阅读(344) 评论(0) 推荐(0)
摘要:[抄题]: Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's per 阅读全文
posted @ 2018-08-11 09:27 苗妙苗 阅读(187) 评论(0) 推荐(0)
摘要:[抄题]: We are given two strings, A and B. A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For exa 阅读全文
posted @ 2018-08-10 22:07 苗妙苗 阅读(301) 评论(0) 推荐(0)
摘要:[抄题]: A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bottom-left corner, and (x2, y2) are the coordi 阅读全文
posted @ 2018-08-10 21:56 苗妙苗 阅读(209) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree, return the values of its boundary in anti-clockwise direction starting from root. Boundary includes left boundary, leaves, 阅读全文
posted @ 2018-08-10 10:34 苗妙苗 阅读(213) 评论(0) 推荐(0)
摘要:[抄题]: Implement an iterator to flatten a 2d vector. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: j必须非空且有下才行j != null && 阅读全文
posted @ 2018-08-10 08:52 苗妙苗 阅读(201) 评论(0) 推荐(0)
摘要:[抄题]: 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 y 阅读全文
posted @ 2018-08-09 17:47 苗妙苗 阅读(208) 评论(0) 推荐(0)
摘要:gas = [1,2,3,4,5], cost = [3,4,5,1,2]index =[0,1,2,3,4]//cost = index - 1 [抄题]: There are N gas stations along a circular route, where the amount of g 阅读全文
posted @ 2018-08-09 16:23 苗妙苗 阅读(291) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node 阅读全文
posted @ 2018-08-09 15:26 苗妙苗 阅读(174) 评论(0) 推荐(0)
摘要:[抄题]: Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时 阅读全文
posted @ 2018-08-08 17:19 苗妙苗 阅读(316) 评论(0) 推荐(0)
摘要:[抄题]: Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertica 阅读全文
posted @ 2018-08-08 10:55 苗妙苗 阅读(323) 评论(0) 推荐(0)
摘要:[抄题]: 就是出现了多次的子树,可以只包括一个点。 Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root n 阅读全文
posted @ 2018-08-08 09:20 苗妙苗 阅读(186) 评论(0) 推荐(0)
摘要:[抄题]: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not 阅读全文
posted @ 2018-08-06 23:25 苗妙苗 阅读(302) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree shoul 阅读全文
posted @ 2018-08-06 09:58 苗妙苗 阅读(158) 评论(0) 推荐(0)
摘要:[抄题]: Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next poin 阅读全文
posted @ 2018-08-05 20:49 苗妙苗 阅读(484) 评论(0) 推荐(0)
摘要:[抄题]: Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list "parts". The length o 阅读全文
posted @ 2018-08-05 09:28 苗妙苗 阅读(145) 评论(0) 推荐(0)
摘要:[抄题]: S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We want 阅读全文
posted @ 2018-08-04 23:14 苗妙苗 阅读(195) 评论(0) 推荐(0)
摘要:[抄题]: Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node v 阅读全文
posted @ 2018-08-04 21:57 苗妙苗 阅读(171) 评论(0) 推荐(0)
摘要:[抄题]: Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary represen 阅读全文
posted @ 2018-08-04 20:56 苗妙苗 阅读(208) 评论(0) 推荐(0)
摘要:[抄题]: You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can fol 阅读全文
posted @ 2018-08-04 15:09 苗妙苗 阅读(310) 评论(0) 推荐(0)
摘要:[抄题]: Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing the game board. 'M' represents an unreveal 阅读全文
posted @ 2018-08-04 10:29 苗妙苗 阅读(380) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we de 阅读全文
posted @ 2018-08-03 23:19 苗妙苗 阅读(188) 评论(0) 推荐(0)
摘要:[抄题]: A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most 阅读全文
posted @ 2018-08-03 21:59 苗妙苗 阅读(234) 评论(0) 推荐(0)
摘要:[抄题]: The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, ea 阅读全文
posted @ 2018-08-03 17:14 苗妙苗 阅读(242) 评论(0) 推荐(0)
摘要:[抄题]: There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a  阅读全文
posted @ 2018-08-03 16:14 苗妙苗 阅读(167) 评论(0) 推荐(0)
摘要:[抄题]: Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / opera 阅读全文
posted @ 2018-08-03 11:22 苗妙苗 阅读(180) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ 阅读全文
posted @ 2018-08-03 10:35 苗妙苗 阅读(328) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appe 阅读全文
posted @ 2018-08-03 08:37 苗妙苗 阅读(311) 评论(0) 推荐(0)
摘要:[抄题]: Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may 阅读全文
posted @ 2018-08-02 22:04 苗妙苗 阅读(135) 评论(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 阅读全文
posted @ 2018-08-02 16:54 苗妙苗 阅读(213) 评论(0) 推荐(0)
摘要:[抄题]: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For exa 阅读全文
posted @ 2018-08-02 15:52 苗妙苗 阅读(159) 评论(0) 推荐(0)
摘要:[抄题]: According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician 阅读全文
posted @ 2018-08-02 09:46 苗妙苗 阅读(199) 评论(0) 推荐(0)
摘要:[抄题]: Given an integer n, return 1 - n in lexicographical order. For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9]. Please optimize your 阅读全文
posted @ 2018-08-01 22:32 苗妙苗 阅读(190) 评论(0) 推荐(0)
摘要:[抄题]: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must e 阅读全文
posted @ 2018-08-01 21:45 苗妙苗 阅读(148) 评论(0) 推荐(0)
摘要:[抄题]: Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0. You may 阅读全文
posted @ 2018-08-01 16:57 苗妙苗 阅读(170) 评论(0) 推荐(0)
摘要:[抄题]: You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes 阅读全文
posted @ 2018-08-01 15:37 苗妙苗 阅读(178) 评论(0) 推荐(0)
摘要:[抄题]: Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: Construct the maximum tree by the given a 阅读全文
posted @ 2018-08-01 11:30 苗妙苗 阅读(131) 评论(0) 推荐(0)