
leetcode
鱼塘里的Aquaman
这个作者很懒,什么都没留下…
展开
-
leetcode(56)
题目描述:Given a collection of intervals, merge all overlapping intervals.For example, Given[1,3],[2,6],[8,10],[15,18], return[1,6],[8,10],[15,18].思路:根据区间的起始项先进行排序,然后两两比较,合并区间。代码:import java.util...原创 2019-08-05 21:24:46 · 227 阅读 · 0 评论 -
leetcode(173) Binary Search Tree Iterator
Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next smallest number ...原创 2019-08-05 22:17:38 · 189 阅读 · 0 评论 -
leetcode(1) 两数之和
题目描述:给定一个整数数组 nums和一个目标值 target,请你在该数组中找出和为目标值的那两个整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。示例:给定 nums = [2, 7, 11, 15], target = 9,因为 nums[0] + nums[1] = 2 + 7 = 9,所以返回 [0, 1]思路:借助H...原创 2019-08-25 23:09:16 · 180 阅读 · 0 评论