LeetCode(63)Unique Paths II】的更多相关文章

题目 Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in the grid. For example, There is one obstacle in the mi…
题目 A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' i…
题目 Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree and sum = 22, 分析 本题目与上一题LeetCode(112) Path Sum虽然类型相同,但是需要在以前的基础上,多做处理一些: 与Path Sum相比,本题是求出路径,所以,在找到满足的路…
Medium! 题目描述: 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在下图中标记为“Finish”). 现在考虑网格中有障碍物.那么从左上角到右下角将会有多少条不同的路径? 网格中的障碍物和空位置分别用 1 和 0 来表示. 说明:m 和 n 的值均不超过 100. 示例 1: 输入: [   [0,0,0],   [0,1,0],   [0,0,0] ] 输出: 2 解释: 3x3…
Medium! 题目描述: 给定一个可能包含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集). 说明:解集不能包含重复的子集. 示例: 输入: [1,2,2] 输出: [ [2], [1], [1,2,2], [2,2], [1,2], [] ] 解题思路: 这道子集合之二是之前那道Subsets 子集合 的延伸,这次输入数组允许有重复项,其他条件都不变,只需要在之前那道题解法的基础上稍加改动便可以做出来,我们先来看非递归解法,拿题目中的例子[1 2 2]来分析,根据之前Subse…
题目 Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k. 分析 题目描述:给定一个整数序列,查找是否存在两个下标分别为i和j的元素值nums[i]=nums[j]且满足i…
题目 Given n, generate all structurally unique BST's (binary search trees) that store values 1-n. For example, Given n = 3, your program should return all 5 unique BST's shown below. confused what "{1,#,2,3}" means? > read more on how binary tr…
题目 Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 分析 由上一题改动而来,LeetCode 136 Single Nu…
题目 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's. 分析 此题与上题本质相同,LeetCode 95 Unique Binary Search Trees要求得到全部二叉查找树,打印其层序遍历序列. 而此题,只要求元素 [1,n] 能构成的二…
题目 Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combination. Note: All numbers (including target) will be p…