一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径? 网格中的障碍物和空位置分别用 1 和 0 ...
分类:
其他好文 时间:
2018-10-09 23:54:24
阅读次数:
183
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, ...
分类:
其他好文 时间:
2018-10-03 23:38:19
阅读次数:
154
Shuffle a set of numbers without duplicates. Example: 给一个没有重复数字的数组,实现重置和洗牌的功能。 解法:遍历数组每个位置,每次都随机生成一个坐标位置,然后交换当前位置和随机位置的数字,这样如果数组有n个数字,那么也随机交换了n组位置,从而达 ...
分类:
编程语言 时间:
2018-10-03 22:12:54
阅读次数:
177
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, ...
分类:
其他好文 时间:
2018-10-03 21:54:52
阅读次数:
120
给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。 你不需要考虑数组中超出新长度后面的元素。说明: 为什么返回数值是整数,但输出的答案是数组呢? 请注意,输入数 ...
分类:
其他好文 时间:
2018-09-29 14:37:00
阅读次数:
128
一、题目 1、审题 2、分析 给出一个有序的有重复数值的整形链表,删除重复值的节点,使得每个节点的值只出现一次。 二、解答 1、思路: 同 eg 82,只是保留重复节点数值的一个节点 ...
分类:
其他好文 时间:
2018-09-24 19:33:51
阅读次数:
120
利用虚拟节点进行删除结点,pre始终指向不重复的钱一个元素,一开始指向虚拟结点。如果遇到重复结点就全部删除再与pre相连接. ...
分类:
其他好文 时间:
2018-09-24 11:26:41
阅读次数:
151
一、题目 1、审题 2、分析 给出一个有序的整数数组,统计总共有多少个元素,其中同一个整数最多只能存在两个,并将统计的所有整数放在数组前头。(只能借助一个额外的空间) 二、解答 1、思路: 方法一、 ①、若数组长度 len <= 2, 则直接返回数组长度。 ②、len > 2时,从下标 i = 2 ...
分类:
其他好文 时间:
2018-09-24 00:51:39
阅读次数:
162
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the ...
分类:
其他好文 时间:
2018-09-23 00:18:57
阅读次数:
145
496. Next Greater Element IYou are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next ...
分类:
其他好文 时间:
2018-09-18 11:04:04
阅读次数:
171