- 博客(119)
- 收藏
- 关注
原创 【LeetCode】116. Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is no next right...
2018-12-10 15:33:24
378
原创 【LeetCode】114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3...
2018-11-12 08:53:42
333
原创 【LeetCode】113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, ...
2018-10-16 09:32:57
341
原创 【LeetCode】112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. Note: A leaf is a node with no children. Example:...
2018-10-13 10:09:53
229
原创 【LeetCode】111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no childre...
2018-10-13 10:05:04
210
原创 【LeetCode】110. Balanced Binary Tree
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 the depth of the two subtrees of every node never diff...
2018-10-13 09:54:42
207
转载 树的高度和深度
用到树的数据结构时,经常会考虑树的高度和深度,但是lz总是搞混了,总虽然比较简单,就是个定义,记住就行了,但是因为长时间总是弄错,所以写一篇博文,加深一下印象 1、树的深度 树的深度可以这样理解,计算一个节点的深度,从根节点算起(记住从1开始计数,而不是0,程序员的通病在这不好使),到该节点所经过的节点数(包括此节点)为树的深度,如下图B的深度为2,k的深度为5.树中最大深度的节点的深度为...
2018-10-13 09:48:25
591
原创 【LeetCode】109. Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which the ...
2018-10-12 20:09:51
195
转载 对齐次坐标的理解
一直对齐次坐标这个概念的理解不够彻底,只见大部分的书中说道“齐次坐标在仿射变换中非常的方便”,然后就没有了后文,今天在一个叫做“三百年 重生”的博客上看到一篇关于透视投影变换的探讨的文章,其中有对齐次坐标有非常精辟的说明,特别是针对这样一句话进行了有力的证明:“齐次坐标表示是计算机图形学的重要手段之一,它既能够用来明确区分向量和点,同时也更易用于进行仿射(线性)几何变换。”—— F.S. Hill...
2018-10-07 10:29:22
256
原创 【LeetCode】108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...
2018-09-09 08:49:49
197
原创 【LeetCode】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...
2018-09-08 22:08:25
197
原创 【LeetCode】106. Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given inorder = [9,3,15,20,7] postorder = [9...
2018-09-06 09:34:42
254
原创 【LeetCode】105. Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given preorder = [3,9,20,15,7] inorder = [9,3...
2018-09-05 15:16:09
229
原创 【LeetCode】103. Binary Tree Zigzag Level Order Traversal
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 alternate between). For example: Given binary tre...
2018-08-17 09:47:57
211
原创 【LeetCode】102. 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 level). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 ...
2018-08-06 15:35:22
207
原创 【LeetCode】101. Symmetric Tree
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 symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 B...
2018-08-06 14:48:36
196
原创 【LeetCode】100. Same Tree
Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Example ...
2018-08-04 20:13:33
194
原创 【LeetCode】98. Validate Binary Search Tree
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 only nodes with keys less than the node's key. The ...
2018-08-04 20:04:52
193
原创 【TensorFlow实战】8.卷积神经网络(2)------LeNet-5模型
LeNet-5模型时Yann LeCun教授于1998年在论文Gradient-bashed learning applied to document recognition中提出的,它是第一个成功应用于数字识别问题的卷积神经网络。在MNIST数据集上,LeNet-5模型可以达到99.2%的正确率。LeNet-5模型总共有7层,下图是LeNet-5模型的架构。 下面介绍LeNet-5模型的每...
2018-08-03 15:43:26
1400
1
原创 【TensorFlow实战】7.卷积神经网络(1)------神经网络主要组成结构
一般卷积神经网络主要由以下5种结构组成: 1.输入层。输入层是整个神经网络的输入,在处理图像的卷积神经网络中,它一般代表了一张图片的像素矩阵。一般由一个三维矩阵表示,三维矩阵的长和宽代表了图像的大小,而三维矩阵的深度代表了图像的彩色通道。比如黑白图像的深度为1,而RGB图项的深度为3。从输入层开始,卷积神经网络通过不同的神经网络结构将上一层的三维矩阵转化为下一层的三维矩阵,直到最后的全连接层。 ...
2018-08-03 14:47:46
616
原创 【TensorFlow实战】4.MNIST数字识别(2)
在实战3给出的程序(点我)来解决MNIST问题,但是这个程序的可扩展性不好。本节例程将训练和测试分成两个独立的程序,这可以使得每一个组件更加灵活。训练神经网络的程序可以持续输出训练好的模型,而测试程序可以每隔一段时间检验最新模型的正确率,如果模型效果更好,则将这个模型供给产品使用。除了将不同功能模块分开,本节还将前向传播过程抽象成一个单独的库函数。因为神经网络的前向传播在训练和测试的过程中都会使用...
2018-08-01 19:54:58
291
原创 【TensorFlow实战】6.损失函数(2)
TensorFlow不仅支持经典的损失函数,还可以任意的自定义损失函数。下面将介绍如何通过自定义损失函数的方法,使得神经网络优化的结果更接近实际问题的需求。在下面的介绍中将以预测商品销量问题为例。 在预测商品销量中,如果预测多了(预测值比实际销量大),商家损失的是生产商品的成本;而如果预测少了(预测值比真实小销量小),损失的是商品的利润。因为一般商品的成本和利润不会严格相等。例如一个商品的成本是...
2018-08-01 19:05:10
294
原创 【TensorFlow实战】5.损失函数(1)
分类问题和回归问题是监督学习的两大类。分类问题希望解决的是将不同的样本分到事先定义好的类别中,比如判断一个零件是否合格就是一个二分类问题。在这个问题中需要将样本(也就是零件)分到合格或者是不合格两个类别中。手写数字体识别问题可以看作是十分类问题,也就是将一张包含了手写数字的图片分类到0~9这十个数字中。 在解决零件是否合格的二分类问题中,定义一个有单个输出节点的神经网络。当这个节点的输出越接近0...
2018-08-01 16:25:27
1162
原创 【LeetCode】96. Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n = 3, there are a total of 5 unique BST's: 1 ...
2018-07-31 22:06:29
439
原创 【LeetCode】94. Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,3,2] Follow up: Recursive solution is trivial, could y...
2018-07-31 21:50:54
148
原创 【LeetCode】93. Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: Input: "25525511135" Output: ["255.255.11.135", "255.255.111.35"] 将一串字符转换成正确的IP...
2018-07-31 21:42:34
181
原创 【LeetCode】92. Reverse Linked List II
Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4 Output: 1->4->3->2->5-...
2018-07-31 21:33:53
217
原创 【LeetCode】91. Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given a non-empty string containing only digits, determine th...
2018-07-31 21:28:13
185
原创 【LeetCode】90. Subsets II
Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Example: Input: [1,2,2] ...
2018-07-31 21:08:20
172
原创 【LeetCode】89. Gray Code
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 number of bits in the code, print the sequence of gr...
2018-07-30 20:40:25
161
原创 【LeetCode】93. Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: Given a string containing only digits, restore it by returning all possible valid...
2018-07-30 20:30:35
202
原创 【TensorFlow实战】3.MNIST数字识别(1)
目前用的时TensorFlow1.8版本,python3.5,跑书上的例子会出问题,并且书上的代码存在一处错误,下面的代码时我亲测可用的。 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data #MNIST数据集相关的常数 INPUT_NODE = 784 #输入层节点数,对于...
2018-07-17 22:47:19
488
原创 【2017CS231n】第十五讲:神经网络模型压缩和加速(硬件、算法层面)
一.算法1.剪枝不是所有的神经网络连接都有用。减少连接,但不降低准确性。尝试性:剪枝,训练不断重复,找到对准确性影响最高的那一部分连接。2.参数共享1.98 2.09 1.92 1.87 都用2来表示,不是所有权重都需要用精确的数字来表示,这样反而可能会造成过拟合。思路:所有权重聚类,如果相近,就用聚类质心来表示其他数。霍夫曼编码:对经常出现使用的权重采用霍夫曼编码3.量化用标准浮点数训练一个网络...
2018-07-04 21:29:43
1242
原创 【2017CS231n】第十四讲:深度增强学习
一.概述 强化学习:我们有一个代理,能够在其环境中采取行动,也可以因为其行动获得奖励,它的目标是学会如何行动以最大限度地获得奖励。 这节主要讲了以下几个问题:什么是强化学习,马尔科夫决策过程(这是对强化学习问题的数学抽象),然后是两类主要的强化学习算法:Q-learning,策略梯度算法。二.强化学习 在强化学习中我们有一个代理和一个环境,环境赋予代理一个状态,反过来代理将采取...
2018-07-04 21:16:58
1550
原创 【LeetCode】86. Partition List
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 the original relative order of the nodes in each of the...
2018-07-03 12:08:19
182
原创 【LeetCode】82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.Example 1:Input: 1->2->3->3->4->4->5 Output: 1->2-&g...
2018-07-02 21:46:21
158
原创 TensorFlow错误:fatal error: tensorflow/core/framework/op.h: 没有那个文件或目录(PointCNN遇到的错误)
跑了PointCNN,基于TensorFlow,遇到了错误,编译的时候找不到头文件。我是Virtualenv方式安装的Tensorflow,但是编译文件tf_sampling_compile.sh里面的路径是这么写的:TF_PATH=/usr/local/lib/python$PYTHON_VERSION/dist-packages/tensorflow/include但是我的TensorFlow...
2018-06-29 10:33:57
15928
12
原创 【LeetCode】81. Search in Rotated Sorted Array II
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).You are given a target value to search. If found in t...
2018-06-28 10:01:50
169
原创 【LeetCode】80. Remove Duplicates from Sorted Array II
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.Do not allocate extra space for another array, you must do this by modif...
2018-06-26 10:40:36
170
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅