08 2017 档案

leetcode--98. Validate Binary Search Tree
摘要:1、问题描述 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 contai 阅读全文

posted @ 2017-08-31 23:19 Shihu 阅读(459) 评论(0) 推荐(0)

leetcode--47. Permutations II
摘要:1、问题描述 Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following un 阅读全文

posted @ 2017-08-31 22:20 Shihu 阅读(226) 评论(0) 推荐(0)

leetcode-- 100. Same Tree
摘要:1、问题描述 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 iden 阅读全文

posted @ 2017-08-31 09:53 Shihu 阅读(139) 评论(0) 推荐(0)

leetcode--101. Symmetric Tree
摘要:1、问题描述 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is 阅读全文

posted @ 2017-08-31 09:53 Shihu 阅读(156) 评论(0) 推荐(0)

leetcode--110. Balanced Binary Tree
摘要:1、问题描述 Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which t 阅读全文

posted @ 2017-08-31 09:53 Shihu 阅读(180) 评论(0) 推荐(0)

leetcode--515. Find Largest Value in Each Tree Row
摘要:1、问题描述 You need to find the largest value in each row of a binary tree. Example: 2、边界条件:root==null 3、思路:层级遍历,每一层找到最大值,记录 4、代码实现 5、api 阅读全文

posted @ 2017-08-31 09:53 Shihu 阅读(118) 评论(0) 推荐(0)

leetcoe--47. Permutations II
摘要:1、问题描述 Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following un 阅读全文

posted @ 2017-08-31 09:52 Shihu 阅读(234) 评论(0) 推荐(0)

Tree--lecture08
摘要:1、二叉树 完全二叉树(complete binary tree):除了最下面一层都是满的,最下面一层也是优先排列在左边。这样的话父亲节点和孩子节点就在序号上面有关系: 父亲节点为n,那么子节点的编号为2n和2n+1。这样就可以操作序号来操作完全二叉树。 A1 / \ B2 C3 / \ / \ D 阅读全文

posted @ 2017-08-31 09:52 Shihu 阅读(163) 评论(0) 推荐(0)

leetcode--257. Binary Tree Paths
摘要:1、问题描述 Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: 2、边界条件:root为null; 阅读全文

posted @ 2017-08-31 09:52 Shihu 阅读(181) 评论(0) 推荐(0)

leetcode--199. Binary Tree Right Side View
摘要:1、问题描述 Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. 阅读全文

posted @ 2017-08-31 01:51 Shihu 阅读(156) 评论(0) 推荐(0)

leetcode-- 90. Subsets II
摘要:1、问题描述 Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplic 阅读全文

posted @ 2017-08-29 01:12 Shihu 阅读(297) 评论(0) 推荐(0)

leetcode--401. Binary Watch
摘要:1、问题描述 A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED repr 阅读全文

posted @ 2017-08-28 00:19 Shihu 阅读(217) 评论(0) 推荐(0)

leetcode-- 79. Word Search
摘要:1、问题描述 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where 阅读全文

posted @ 2017-08-27 19:21 Shihu 阅读(233) 评论(0) 推荐(0)

leetcode--51. N-Queens
摘要:1、问题描述: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, ret 阅读全文

posted @ 2017-08-27 14:21 Shihu 阅读(189) 评论(0) 推荐(0)

leecode-39. Combination Sum
摘要:1、问题描述: Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbe 阅读全文

posted @ 2017-08-27 13:34 Shihu 阅读(192) 评论(0) 推荐(0)

课堂笔记
摘要:1.拓扑排序 阅读全文

posted @ 2017-08-27 11:31 Shihu 阅读(131) 评论(0) 推荐(0)

linkedlist--lecture-4
摘要:1、链表数据结构 内存利用率高;动态分配 2、链表类定义 单向链表节点 public calss ListNode { int val =0; ListNode next = null; public void Node(int val_) { this.val = val_; this.next 阅读全文

posted @ 2017-08-26 21:00 Shihu 阅读(449) 评论(0) 推荐(0)

lecture-7 递归
摘要:1、例题--排列 Permutation Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2 阅读全文

posted @ 2017-08-26 21:00 Shihu 阅读(203) 评论(0) 推荐(0)

[LeetCode]169. Majority Element
摘要:1.Description Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may a 阅读全文

posted @ 2017-08-26 20:59 Shihu 阅读(289) 评论(0) 推荐(0)

234. Palindrome Linked List
摘要:旋转链表函数 public ListNode reverse(ListNode head) { ListNode prev = null; while (head != null) { ListNode next = head.next; head.next = prev; prev = head; 阅读全文

posted @ 2017-08-26 20:58 Shihu 阅读(315) 评论(0) 推荐(0)

[LeetCode]189. Rotate Array
摘要:1、题目描述 Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3, 阅读全文

posted @ 2017-08-10 21:34 Shihu 阅读(149) 评论(0) 推荐(0)

红黑树
摘要:1、红黑树的限制条件 1)红黑树的节点是有颜色的,红色或者黑色 2)根节点是黑色的 3)每个叶子节点(叶节点即指树尾端NIL指针或NULL节点)是黑色的 4)如果一个节点是红色的,那么它的两个子节点都是黑色的;推论,不存在两个红色节点是相邻的。 5)从一个节点开始到每个叶子节点的简单路径上面的黑色节 阅读全文

posted @ 2017-08-02 20:40 Shihu 阅读(187) 评论(0) 推荐(0)

二叉排序树
摘要:1、二叉排序树删除节点P 假设节点P是节点F的左子树 1)节点P无子节点 直接删除,其他节点不动。 2)节点P只有左子节点Pl或者右子节点Pr 删除P,将Pl或者Pr挂载为F节点的左子树。如果P为F的右子树,则挂载为F的右子树。这样也不会破坏二叉排序树的特性(指排序的变化)。 3)节点P既有左子树P 阅读全文

posted @ 2017-08-02 20:33 Shihu 阅读(195) 评论(0) 推荐(0)

导航