上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页

2018年11月8日

418. Sentence Screen Fitting

摘要: Given a rows x cols screen and a sentence represented by a list of non-empty words, find how many times the given sentence can be fitted on the screen 阅读全文

posted @ 2018-11-08 02:21 猪猪🐷 阅读(104) 评论(0) 推荐(0)

295 Find Median from Data Stream

摘要: Approach #3 Two Heaps! [Accepted] Intuition The above two approaches gave us some valuable insights on how to tackle this problem. Concretely, one can 阅读全文

posted @ 2018-11-08 02:21 猪猪🐷 阅读(125) 评论(0) 推荐(0)

480. Sliding Window Median

摘要: Approach #2 Two Heaps! (Lazy Removal) [Accepted] Intuition The idea is the same as Approach #3 from 295. Find Median From Data Stream. The only additi 阅读全文

posted @ 2018-11-08 02:19 猪猪🐷 阅读(182) 评论(0) 推荐(0)

438. Find All Anagrams in a String

摘要: https://www.youtube.com/watch?v=86fQQ7rVGxA&t=284s Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and ... 阅读全文

posted @ 2018-11-08 02:19 猪猪🐷 阅读(118) 评论(0) 推荐(0)

567. Permutation in String

摘要: 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 permutations is the substring of the second string. Exampl... 阅读全文

posted @ 2018-11-08 02:18 猪猪🐷 阅读(89) 评论(0) 推荐(0)

187. Repeated DNA Sequences

摘要: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Write... 阅读全文

posted @ 2018-11-08 02:17 猪猪🐷 阅读(121) 评论(0) 推荐(0)

217. Contains Duplicate

摘要: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element i... 阅读全文

posted @ 2018-11-08 02:16 猪猪🐷 阅读(92) 评论(0) 推荐(0)

219. Contains Duplicate II

摘要: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.... 阅读全文

posted @ 2018-11-08 02:15 猪猪🐷 阅读(72) 评论(0) 推荐(0)

243. Shortest Word Distance

摘要: Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. Example:
Assume that words = ["practice", "makes", "perfect", "coding", "makes"]... 阅读全文

posted @ 2018-11-08 02:14 猪猪🐷 阅读(93) 评论(0) 推荐(0)

220. Contains Duplicate III

摘要: Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference... 阅读全文

posted @ 2018-11-08 02:14 猪猪🐷 阅读(120) 评论(0) 推荐(0)

244. Shortest Word Distance II

摘要: Design a class which receives a list of words in the constructor, and implements a method that takes two words word1 and word2 and return the shortest distance between these two words in the list. Yo... 阅读全文

posted @ 2018-11-08 02:13 猪猪🐷 阅读(101) 评论(0) 推荐(0)

3 Longest Substring Without Repeating Characters

摘要: Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Inpu... 阅读全文

posted @ 2018-11-08 02:12 猪猪🐷 阅读(93) 评论(0) 推荐(0)

487. Max Consecutive Ones II

摘要: Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most one 0. Example 1: Input: [1,0,1,1,0] Output: 4 Explanation: Flip the first zero will get the the... 阅读全文

posted @ 2018-11-08 02:09 猪猪🐷 阅读(119) 评论(0) 推荐(0)

683. K Empty Slots

摘要: There is a garden with N slots. In each slot, there is a flower. The N flowers will bloom one by one in N days. In each day, there will be exactly one flower blooming and it will be in the status of ... 阅读全文

posted @ 2018-11-08 02:08 猪猪🐷 阅读(137) 评论(0) 推荐(0)

659. Split Array into Consecutive Subsequences

摘要: You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into several subsequences, where each subsequences consist of at least 3 consecutive integers... 阅读全文

posted @ 2018-11-08 02:07 猪猪🐷 阅读(128) 评论(0) 推荐(0)

606. Construct String from Binary Tree

摘要: You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be represented by empty parenthesis pair "()". And you ... 阅读全文

posted @ 2018-11-08 02:05 猪猪🐷 阅读(99) 评论(0) 推荐(0)

424. Longest Repeating Character Replacement

摘要: Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the length of a longest substring containing all rep... 阅读全文

posted @ 2018-11-08 01:42 猪猪🐷 阅读(85) 评论(0) 推荐(0)

354. Russian Doll Envelopes

摘要: lamda expression and n^2 longest increasing subsequence int[] = width, height lamda expression and binary search in longest increasing subsequence 阅读全文

posted @ 2018-11-08 01:40 猪猪🐷 阅读(119) 评论(0) 推荐(0)

2018年11月7日

331. Verify Preorder Serialization of a Binary Tree

摘要: One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #. ... 阅读全文

posted @ 2018-11-07 05:29 猪猪🐷 阅读(107) 评论(0) 推荐(0)

439. Ternary Expression Parser

摘要: Given a string representing arbitrarily nested ternary expressions, calculate the result of the expression. You can always assume that the given expression is valid and only consists of digits 0-9, ?... 阅读全文

posted @ 2018-11-07 05:28 猪猪🐷 阅读(92) 评论(0) 推荐(0)

536. Construct Binary Tree from String

摘要: You need to construct a binary tree from a string consisting of parenthesis and integers. The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parent... 阅读全文

posted @ 2018-11-07 05:28 猪猪🐷 阅读(78) 评论(0) 推荐(0)

339. Nested List Weight Sum

摘要: Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists... 阅读全文

posted @ 2018-11-07 05:27 猪猪🐷 阅读(107) 评论(0) 推荐(0)

364. Nested List Weight Sum II

摘要: Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists... 阅读全文

posted @ 2018-11-07 05:26 猪猪🐷 阅读(79) 评论(0) 推荐(0)

671. Second Minimum Node In a Binary Tree

摘要: Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly twoor zero sub-node. If the node has two sub-nodes, then this node's va... 阅读全文

posted @ 2018-11-07 05:19 猪猪🐷 阅读(86) 评论(0) 推荐(0)

107. Binary Tree Level Order Traversal II

摘要: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:
Given binary tree [3,9,20,null,null,15,7... 阅读全文

posted @ 2018-11-07 05:16 猪猪🐷 阅读(70) 评论(0) 推荐(0)

515. Find Largest Value in Each Tree Row

摘要: You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9] Bfs public int[] findV... 阅读全文

posted @ 2018-11-07 05:14 猪猪🐷 阅读(94) 评论(0) 推荐(0)

662. Maximum Width of Binary Tree

摘要: 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 binary tree has the same structure as a full binary tr... 阅读全文

posted @ 2018-11-07 05:13 猪猪🐷 阅读(81) 评论(0) 推荐(0)

333. Largest BST Subtree

摘要: 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 it. Note:
A subtree must include all of its descendants.... 阅读全文

posted @ 2018-11-07 05:11 猪猪🐷 阅读(91) 评论(0) 推荐(0)

652. Find Duplicate Subtrees

摘要: Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them. Two trees are duplicate if they have the same struct... 阅读全文

posted @ 2018-11-07 05:10 猪猪🐷 阅读(88) 评论(0) 推荐(0)

572. Subtree of Another Tree

摘要: , 3, 4, 1, #, #, 2, 0, #, #, #, 5, #, # , 4, 1, #, #, 2, #, # , 3, 4, 1, #, #, 2, #, #, 5, #, # 阅读全文

posted @ 2018-11-07 05:10 猪猪🐷 阅读(97) 评论(0) 推荐(0)

742. Closest Leaf in a Binary Tree

摘要: Given a binary tree where every node has a unique value, and a target key k, find the value of the nearest leaf node to target k in the tree. Here, nearest to a leaf means the least number of edges t... 阅读全文

posted @ 2018-11-07 05:09 猪猪🐷 阅读(96) 评论(0) 推荐(0)

501. Find Mode in Binary Search Tree

摘要: Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is defined as follows: * The left subtree of a node contai... 阅读全文

posted @ 2018-11-07 05:08 猪猪🐷 阅读(129) 评论(0) 推荐(0)

783. Minimum Distance Between BST Nodes

摘要: Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree. Example : Input: root = [4,2,6,1,3,null,null] Output... 阅读全文

posted @ 2018-11-07 05:07 猪猪🐷 阅读(103) 评论(0) 推荐(0)

776. Split BST

摘要: 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 are all smaller or equal to the target value, while the o... 阅读全文

posted @ 2018-11-07 05:06 猪猪🐷 阅读(133) 评论(0) 推荐(0)

538. Convert BST to Greater Tree

摘要: Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. Exampl... 阅读全文

posted @ 2018-11-07 05:06 猪猪🐷 阅读(76) 评论(0) 推荐(0)

255. Verify Preorder Sequence in Binary Search Tree

摘要: Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree. You may assume each number in the sequence is unique. Consider the following binary se... 阅读全文

posted @ 2018-11-07 05:05 猪猪🐷 阅读(135) 评论(0) 推荐(0)

669. Trim a Binary Search Tree

摘要: Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the resu... 阅读全文

posted @ 2018-11-07 05:05 猪猪🐷 阅读(116) 评论(0) 推荐(0)

215. Kth Largest Element in an Array

摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Examp... 阅读全文

posted @ 2018-11-07 04:58 猪猪🐷 阅读(143) 评论(0) 推荐(0)

2018年11月6日

726. Number of Atoms

摘要: Given a chemical formula (given as a string), return the count of each atom. An atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name. 1... 阅读全文

posted @ 2018-11-06 11:56 猪猪🐷 阅读(159) 评论(0) 推荐(0)

294. Flip Game II

摘要: You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The g... 阅读全文

posted @ 2018-11-06 11:55 猪猪🐷 阅读(91) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页

导航