Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the ...
分类:
系统相关 时间:
2016-08-23 22:00:16
阅读次数:
237
http://acm.fzu.edu.cn/problem.php?pid=2128 分析:利用strstr()函数将每个字串在原串中的首尾位置存储一下,再将首尾从小到大排一下序。(写着写着就感觉和看电视节目那一道题一样一样的啊~) 例子: aaaa 2 aa aa 答案:1 abc 1 d 答案: ...
分类:
其他好文 时间:
2016-08-23 11:36:25
阅读次数:
284
今天阅读《设计模式示例》,看到一段代码涉及到了interface,implements和extends,其实在C++中经常用到。今天特百度,比较了一下: interface是一个接口,类似于C++中的纯虚函数。举个简单的例子,有一类东西,都具有同样的行为,而这个共有的行为实现方式不一样。如:笔这类东 ...
分类:
编程语言 时间:
2016-08-22 19:39:33
阅读次数:
152
Implement a trie with insert, search, and startsWith methods. Note: You may assume that all inputs are consist of lowercase letters a-z. Solution: ...
分类:
其他好文 时间:
2016-08-22 09:30:22
阅读次数:
207
文字部分转自:http://www.cnblogs.com/mr-ghostaqi/p/4285868.html 代码是我自己写的 今天在做LeetCode的时候,碰到一个写字符串匹配的题目: https://oj.leetcode.com/problems/implement-strstr/ 我一 ...
分类:
编程语言 时间:
2016-08-21 22:48:35
阅读次数:
309
1. stack(先进后出): pop 拿出并返回最后值; peek 返回最后值; push 加入新值在后面并返回此值。 2. queue(先进先出) : poll = remove 拿出并返第一个值; element = peek 返第一个值; add = offer 加入新值在后面并返回true ...
分类:
其他好文 时间:
2016-08-21 15:10:03
阅读次数:
179
在上一篇学习过HashMap(源码解读—HashMap)之后对hashTable也产生了兴趣,随即便把hashTable的源码看了一下。和hashMap类似,但是也有不同之处。 public class Hashtable<K,V> extends Dictionary<K,V> implement ...
分类:
其他好文 时间:
2016-08-21 13:39:34
阅读次数:
194
题目: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not po ...
分类:
其他好文 时间:
2016-08-20 00:10:50
阅读次数:
167
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the n ...
分类:
其他好文 时间:
2016-08-18 00:49:41
阅读次数:
157
题目链接: https://oj.leetcode.com/problems/string-to-integer-atoi/ 问题: Implement atoi to convert a string to an integer. Notes: It is intended for this pr ...
分类:
其他好文 时间:
2016-08-17 11:56:18
阅读次数:
115