随笔分类 -  leetcode

摘要: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 阅读全文
posted @ 2018-10-28 21:16 Lin.B 阅读(215) 评论(0) 推荐(0)
摘要:Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: The root is the maximum number in the array. Th 阅读全文
posted @ 2018-10-18 17:56 Lin.B 阅读(206) 评论(0) 推荐(0)
摘要:Given a binary tree, return the preorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,2,3] Follow up: Recursive s 阅读全文
posted @ 2018-10-18 15:10 Lin.B 阅读(108) 评论(0) 推荐(0)
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文
posted @ 2018-10-18 14:47 Lin.B 阅读(141) 评论(0) 推荐(0)
摘要:Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: All letters in hexadec 阅读全文
posted @ 2018-10-16 19:41 Lin.B 阅读(192) 评论(0) 推荐(0)
摘要:Binary Tree Level Order Traversal Ⅰ Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by leve 阅读全文
posted @ 2018-10-12 21:59 Lin.B 阅读(151) 评论(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: Input:nums = 阅读全文
posted @ 2018-10-10 14:23 Lin.B 阅读(172) 评论(0) 推荐(0)
摘要:Given an integer, write a function to determine if it is a power of three. Example 1: Input: 27 Output: true Example 2: Input: 0 Output: false Example 阅读全文
posted @ 2018-10-08 20:55 Lin.B 阅读(142) 评论(0) 推荐(0)
摘要:Given a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and o 阅读全文
posted @ 2018-10-07 22:35 Lin.B 阅读(141) 评论(0) 推荐(0)
摘要:Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. For example, in the given t 阅读全文
posted @ 2018-10-07 19:34 Lin.B 阅读(146) 评论(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) of th 阅读全文
posted @ 2018-10-05 20:50 Lin.B 阅读(128) 评论(0) 推荐(0)
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Output: 1 Example 2: Input: 1 / \ 2 3 / / \ 4 5 阅读全文
posted @ 2018-10-04 20:37 Lin.B 阅读(99) 评论(0) 推荐(0)
摘要:Unique Paths Ⅰ 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 阅读全文
posted @ 2018-10-02 21:47 Lin.B 阅读(107) 评论(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 @ 2018-10-02 17:37 Lin.B 阅读(134) 评论(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 one p 阅读全文
posted @ 2018-10-02 14:01 Lin.B 阅读(195) 评论(0) 推荐(0)
摘要:Given an unsorted integer array, find the smallest missing positive integer. Example 1: Input: [1,2,0] Output: 3 Example 2: Input: [3,4,-1,1] Output: 阅读全文
posted @ 2018-09-28 14:25 Lin.B 阅读(170) 评论(0) 推荐(0)
摘要:Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they 阅读全文
posted @ 2018-09-27 17:48 Lin.B 阅读(193) 评论(0) 推荐(0)
摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Example 2: Inp 阅读全文
posted @ 2018-09-26 23:55 Lin.B 阅读(121) 评论(0) 推荐(0)
摘要: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: [ 阅读全文
posted @ 2018-09-16 11:50 Lin.B 阅读(136) 评论(0) 推荐(0)
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and num 阅读全文
posted @ 2018-09-02 22:51 Lin.B 阅读(145) 评论(0) 推荐(0)