摘要: 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 on 阅读全文
posted @ 2018-10-12 02:48 jasminemzy 阅读(321) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe 阅读全文
posted @ 2018-10-11 13:08 jasminemzy 阅读(197) 评论(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: Input: [ ["1","0","1"," 阅读全文
posted @ 2018-10-11 05:41 jasminemzy 阅读(180) 评论(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 @ 2018-10-10 08:22 jasminemzy 阅读(208) 评论(0) 推荐(0) 编辑
摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 1 1 阅读全文
posted @ 2018-10-10 03:43 jasminemzy 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Given the head of a graph, return a deep copy (clone) of the graph. Each node in the graph contains a label (int) and a list (List[UndirectedGraphNode 阅读全文
posted @ 2018-10-10 02:39 jasminemzy 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the space 阅读全文
posted @ 2018-10-04 11:19 jasminemzy 阅读(560) 评论(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 proport 阅读全文
posted @ 2018-10-04 11:18 jasminemzy 阅读(521) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 分治法 1.解决自己小三角,交换左右直接孩子。 2.递归,让自己的左右孩子也去做这件事情。 实现: /* 阅读全文
posted @ 2018-10-04 03:15 jasminemzy 阅读(250) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: num 阅读全文
posted @ 2018-10-03 15:04 jasminemzy 阅读(182) 评论(0) 推荐(0) 编辑