leetcode
mayihi
这个作者很懒,什么都没留下…
展开
-
二分查找问题模板
刷题不在多、不在快,在于理解并记住。二分查找问题每次都去扣边界情况的话,太浪费时间,而且也容易出错。下面就给出一个最基本的二分查找问题的标准模板,仅供参考。问题描述:给定一个有序数组,求出某个数n的下标,若不存在返回-1,数组中没有重复元素。标准模板:int binarySearch(int [] arr, int n){ if(arr == null || arr.length ==...原创 2020-04-14 20:07:46 · 171 阅读 · 0 评论 -
leetcode96-不同构的二叉搜索树的个数/卡特兰数
给出一个 n, 用二叉搜索树来存储1 … n,总共有多少种不同构的二叉搜索树?Example:输入: 3输出: 5解释:给出 n = 3, 总共有5种不同构的二叉搜索树: 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2...原创 2018-12-03 12:25:32 · 788 阅读 · 0 评论 -
和为K的子数组-leetCode560
题目描述:给定一个整数数组和一个整数 k,你需要找到该数组中和为 k 的连续的子数组的个数。示例 1 :输入:nums = [1,1,1], k = 2输出: 2 , [1,1] 与 [1,1] 为两种不同的情况。说明 : 数组的长度为 [1, 20,000]。 数组中元素的范围是 [-1000, 1000] ,且原创 2018-12-03 12:36:45 · 251 阅读 · 0 评论 -
二叉树的右视图-leetcode199
给定一棵二叉树,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。示例:输入: [1,2,3,null,5,null,4]输出: [1, 3, 4]解释: 1 <--- / \2 3 <--- \ \ 5 4 <---这又是一道二叉树分层的题目,与...原创 2018-12-03 12:52:53 · 1135 阅读 · 0 评论 -
leetcode63-Unique Paths II/独特路径II
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 bot...原创 2018-12-03 12:54:21 · 140 阅读 · 0 评论 -
leetcode-64. Minimum Path Sum/最小路径和
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at an...原创 2018-12-03 12:56:20 · 102 阅读 · 0 评论