
leetcode
Promise_kk
这个作者很懒,什么都没留下…
展开
-
leetcode(1)
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. public class Solution { public int r原创 2017-05-21 23:53:28 · 224 阅读 · 0 评论 -
leetcode(2)
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or another expression. public class Solution { public in原创 2017-05-21 23:58:28 · 167 阅读 · 0 评论 -
leetcode(3)
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. public class Solution { public int maxPoints(Point[] points) { if(points.length==1){原创 2017-05-22 00:00:15 · 196 阅读 · 0 评论 -
用归并排序列表(常数空间复杂度)
Sort a linked list in O(n log n) time using constant space complexity. public class Solution { public ListNode sortList(ListNode head) { if(head==null||head.next==null){ ret原创 2017-05-22 00:02:21 · 725 阅读 · 1 评论 -
合唱团
题目描述 有 n 个学生站成一排,每个学生有一个能力值,牛牛想从这 n 个学生中按照顺序选取 k 名学生,要求相邻两个学生的位置编号的差不超过 d,使得这 k 个学生的能力值的乘积最大,你能返回最大的乘积吗? 输入描述: 每个输入包含 1 个测试用例。每个测试数据的第一行包含一个整数 n (1 <= n <= 50),表示学生的个数,接下来的一行,包含 n 个整数,按顺序表示每个学生的能力值原创 2017-08-19 18:08:19 · 216 阅读 · 0 评论 -
地牢逃脱(BFS)
题目描述 给定一个 n 行 m 列的地牢,其中 ‘.’ 表示可以通行的位置,’X’ 表示不可通行的障碍,牛牛从 (x0 , y0 ) 位置出发,遍历这个地牢,和一般的游戏所不同的是,他每一步只能按照一些指定的步长遍历地牢,要求每一步都不可以超过地牢的边界,也不能到达障碍上。地牢的出口可能在任意某个可以通行的位置上。牛牛想知道最坏情况下,他需要多少步才可以离开这个地牢。 输入描述: 每个输入包含原创 2017-08-23 11:32:31 · 218 阅读 · 0 评论 -
数组中的逆序对(归并排序思路)
题目描述 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数P。并将P对1000000007取模的结果输出。 即输出P%1000000007 输入描述: 题目保证输入的数组中没有的相同的数字 数据范围: 对于%50的数据,size<=10^4 对于%75的数据,size<=10^5 对于%1原创 2017-09-03 10:42:14 · 386 阅读 · 0 评论