Implement a trie with insert, search, and startsWith methods. Notice You may assume that all inputs are consist of lowercase letters a-z. Implement a ...
分类:
其他好文 时间:
2018-12-15 10:27:01
阅读次数:
134
这是悦乐书的第 195 次更新,第 201 篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第57题(顺位题号是232)。使用栈实现队列的以下操作。 push(x) 将元素x推送到队列的后面。 pop() 从队列前面删除元素。 peek() 获取前面的元素。 empty( ...
分类:
编程语言 时间:
2018-12-08 14:43:24
阅读次数:
252
实现 strStr() 函数。 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回 -1。 示例 1: 示例 2: 说明: 当 needle 是空字符串时,我们应当返回什么值呢?这 ...
分类:
其他好文 时间:
2018-12-03 23:06:23
阅读次数:
240
只需检测和要搜索单词长度一样的单词即可,所以我们用的数据结构就是根据单词的长度来分,把长度相同相同的单词放到一起,这样就可以减少搜索量。那么对于和要搜索单词进行比较的单词,由于已经保证了长度相等,我们直接进行逐个字符比较即可,用cnt表示不同字符的个数,初始化为0。如果当前遍历到的字符相等,则con ...
分类:
其他好文 时间:
2018-12-03 10:31:17
阅读次数:
184
程序:有序严谨的指令集 进程:程序的同时多运行 线程:程序中不同的执行路径 线程同步: 是指一段程序执行过程中,无论成功还是失败,其他线程都会等待这段程序执行完毕,才会转入其他线程 extend Thread, 重写run方法, 直接new 调用start() implement Runnable ...
分类:
编程语言 时间:
2018-12-01 22:02:54
阅读次数:
199
A Range Module is a module that tracks ranges of numbers. Your task is to design and implement the following interfaces in an efficient manner. addRan ...
分类:
其他好文 时间:
2018-12-01 15:20:16
阅读次数:
140
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the ...
分类:
系统相关 时间:
2018-12-01 11:10:21
阅读次数:
205
https://leetcode.com/problems/implement-queue-using-stacks/ Implement the following operations of a queue using stacks. push(x) -- Push element x to t ...
分类:
其他好文 时间:
2018-11-30 15:38:04
阅读次数:
104
CountDownLatch是在java1.5被引入的,跟它一起被引入的并发工具类还有CyclicBarrier、Semaphore、ConcurrentHashMap和BlockingQueue,它们都存在于java.util.concurrent包下。CountDownLatch这个类能够使一个 ...
分类:
编程语言 时间:
2018-11-30 13:51:56
阅读次数:
181
Given two 1d vectors, implement an iterator to return their elements alternately. Example: Follow up: What if you are given k 1d vectors? How well can ...
分类:
其他好文 时间:
2018-11-29 15:18:56
阅读次数:
160