上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 30 下一页

2018年1月19日

jump game II

摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文

posted @ 2018-01-19 16:06 夜的第八章 阅读(145) 评论(0) 推荐(0) 编辑

2018年1月18日

小题目(错题)

摘要: 1、 public class StringDemo{ private static final String MESSAGE="taobao"; public static void main(String [] args) { String a ="tao"+"bao"; String b="t 阅读全文

posted @ 2018-01-18 21:53 夜的第八章 阅读(224) 评论(0) 推荐(0) 编辑

星际穿越(网易)

摘要: 题目描述 航天飞行器是一项复杂而又精密的仪器,飞行器的损耗主要集中在发射和降落的过程,科学家根据实验数据估计,如果在发射过程中,产生了 x 程度的损耗,那么在降落的过程中就会产生 x2 程度的损耗,如果飞船的总损耗超过了它的耐久度,飞行器就会爆炸坠毁。问一艘耐久度为 h 的飞行器,假设在飞行过程中不 阅读全文

posted @ 2018-01-18 21:34 夜的第八章 阅读(99) 评论(0) 推荐(0) 编辑

sort list(给链表排序)

摘要: Sort a linked list in O(n log n) time using constant space complexity. 题目要求使用O(nlogn)时间复杂度,可以考虑使用归并排序,在 merge two sorted lists 中,已经知道了将两个有序链表进行合并。这里只要 阅读全文

posted @ 2018-01-18 10:59 夜的第八章 阅读(299) 评论(0) 推荐(0) 编辑

2018年1月17日

reorder list(链表重新排序)

摘要: Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For 阅读全文

posted @ 2018-01-17 16:32 夜的第八章 阅读(150) 评论(0) 推荐(0) 编辑

数据流中的中位数

摘要: 如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。 分析: 中位数就是数据排序前一部分的最后一个(最大值)和后半部分的第一个(最小值)的平均。当元素个数为奇数个时可 阅读全文

posted @ 2018-01-17 14:52 夜的第八章 阅读(267) 评论(2) 推荐(1) 编辑

insertion sort list (使用插入排序给链表排序)

摘要: Sort a linked list using insertion sort. 对于数组的插入排序,可以参看排序算法入门之插入排序(java实现),遍历每个元素,然后相当于把每个元素插入到前面已经排好序的数组里,对于数组,只要当前元素比前一个元素小,则前一个元素后移,然后继续跟再前面的元素比。 对 阅读全文

posted @ 2018-01-17 12:57 夜的第八章 阅读(305) 评论(0) 推荐(0) 编辑

Copy List with Random Pointer(复杂链表复制)

摘要: 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head。(注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空) 第一种方法:使用map存放原节点和其复制节点。然后再给复制节点的next/rando 阅读全文

posted @ 2018-01-17 10:40 夜的第八章 阅读(130) 评论(0) 推荐(0) 编辑

2018年1月16日

二维数组中查找

摘要: 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 由题目知,可以对每一行使用二分查找。但是这样并没有完全利用题目所给的条件。 阅读全文

posted @ 2018-01-16 14:59 夜的第八章 阅读(119) 评论(0) 推荐(0) 编辑

2018年1月15日

gas station

摘要: Gas Station There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank 阅读全文

posted @ 2018-01-15 18:51 夜的第八章 阅读(184) 评论(0) 推荐(0) 编辑

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 30 下一页

导航