随笔分类 -  leetcode

上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array A =[1,1,1,2,2,3], Your function should 阅读全文
posted @ 2017-06-26 14:35 鸭子船长 阅读(152) 评论(0) 推荐(0)
摘要:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a functio 阅读全文
posted @ 2017-06-26 10:26 鸭子船长 阅读(201) 评论(0) 推荐(0)
摘要:【题目】 Suppose a sorted array 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). You are given a targ 阅读全文
posted @ 2017-06-23 23:26 鸭子船长 阅读(216) 评论(0) 推荐(0)
摘要:I、Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given1->1->2, return1->2.Given1->1->2->3->3, 阅读全文
posted @ 2017-06-23 23:11 鸭子船长 阅读(161) 评论(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 @ 2017-06-23 22:56 鸭子船长 阅读(288) 评论(0) 推荐(0)
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. PS:将其化解为柱状图求最大体积的问题。先用动态规划的思路,将矩 阅读全文
posted @ 2017-06-23 22:50 鸭子船长 阅读(1168) 评论(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 阅读全文
posted @ 2017-06-23 15:24 鸭子船长 阅读(269) 评论(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 @ 2017-06-23 15:11 鸭子船长 阅读(235) 评论(0) 推荐(0)
摘要:Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space to hold additional elements 阅读全文
posted @ 2017-06-23 14:33 鸭子船长 阅读(206) 评论(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 @ 2017-06-23 14:29 鸭子船长 阅读(308) 评论(0) 推荐(0)
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t 阅读全文
posted @ 2017-06-21 17:59 鸭子船长 阅读(318) 评论(0) 推荐(0)
摘要:I Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must 阅读全文
posted @ 2017-06-21 12:14 鸭子船长 阅读(217) 评论(0) 推荐(0)
摘要:Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given1->2->3->4->5->NULL, m = 2 and n = 4, return1->4->3->2->5 阅读全文
posted @ 2017-06-21 10:45 鸭子船长 阅读(162) 评论(0) 推荐(0)
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["2 阅读全文
posted @ 2017-06-21 00:10 鸭子船长 阅读(260) 评论(0) 推荐(0)
摘要:Given a binary tree, return the inordertraversal of its nodes' values. For example:Given binary tree{1,#,2,3}, return[1,3,2]. 阅读全文
posted @ 2017-06-20 22:39 鸭子船长 阅读(255) 评论(0) 推荐(0)
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST' 阅读全文
posted @ 2017-06-20 22:26 鸭子船长 阅读(353) 评论(0) 推荐(0)
摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", ret 阅读全文
posted @ 2017-06-20 19:59 鸭子船长 阅读(196) 评论(0) 推荐(0)
摘要:【题目】 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 阅读全文
posted @ 2017-06-20 17:57 鸭子船长 阅读(341) 评论(0) 推荐(0)
摘要:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is 阅读全文
posted @ 2017-06-18 23:24 鸭子船长 阅读(226) 评论(0) 推荐(0)
摘要:Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2017-06-18 22:52 鸭子船长 阅读(227) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页