摘要: 思路1:环形链表,每次只删除一个数,都从第0个开始。每次都从链表重复遍历,每删除一个,走m步,共n遍 时间O(nm),空间o(n) import java.util.*; public class Solution { public int LastRemaining_Solution(int n, 阅读全文
posted @ 2017-07-01 16:19 Scarlett meng 阅读(201) 评论(0) 推荐(0)
摘要: import java.util.Arrays; public class Solution { public boolean isContinuous(int [] numbers) { //数组不能为空,也不能长度小于5 if (numbers == null || numbers.length 阅读全文
posted @ 2017-07-01 15:44 Scarlett meng 阅读(434) 评论(0) 推荐(0)
摘要: 思路1:用额外存储元素,然后遍历输出。如栈或arrayList,前插入,没错都插入到最前面的节点。 import java.util.ArrayList; public class Solution { public ArrayList<Integer> printListFromTailToHea 阅读全文
posted @ 2017-07-01 13:36 Scarlett meng 阅读(261) 评论(0) 推荐(0)
摘要: 思路:若在同一个字符串移动,先遍历出空格个数,开辟空间,再从后往前遍历和复制。若允许新的空间,可随意。 solution1: public class Solution { public String replaceSpace(StringBuffer str) { if(str == null | 阅读全文
posted @ 2017-07-01 13:31 Scarlett meng 阅读(1183) 评论(0) 推荐(0)