- 博客(6)
- 资源 (2)
- 问答 (1)
- 收藏
- 关注
原创 Single Number II
Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without usi
2015-03-27 19:18:51 432
原创 简单工厂和工厂方法
简单工厂:一个工厂类根据传入的参量决定创建出哪一种产品类的实例 直接一个工厂类,内部通过 swith(operator) { case"+": oper=new AddOperation();//产生对象 ... 而工厂方法模式:定义一个用于创建对象的接口,让子类决定实例化哪一个类。工厂方法使一个类的实例化延迟到其子类。 定义一个接口 DAO Add类实现该接口:Ad
2015-03-27 16:28:23 298
原创 Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Update (2014-11-02): The signature of the function had been updat
2015-03-27 13:50:05 369
原创 Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space? /** * Definition for singly-linked l
2015-03-26 23:17:04 275
原创 Linked List Cycle
//快慢指针 public class Solution { public boolean hasCycle(ListNode head) { if(head==null)return false; ListNode slow=head; ListNode fast=head; do{ if(fast==null||fast.next==null)return false; f
2015-03-26 22:34:22 290
原创 剑指offer总结
1、实现Singleton模式 2、二维数组中的查找:每行从左到右递增,每列从上到下递增,输入一个数,判断数组中是否存在该数 1 2 8 9 2 4 9 12 4 7 10 13 6 8 11 15 如输入7: 小于第4列的9,则不可能在第4列;column-- 小于第3列的8,则不可能在第3列;column-- 大于第二列的2,则row++; 始终比较右上角的
2015-03-26 15:06:38 365
在O(n)时间复杂度O(1)空间复杂度求一个数组中出现多次和未出现的数字
2015-05-08
TA创建的收藏夹 TA关注的收藏夹
TA关注的人