摘要: Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs are consist of lowercase letters a-z. 解法: Trie(字典树)的 阅读全文
posted @ 2017-02-21 23:34 Strugglion 阅读(483) 评论(0) 推荐(0) 编辑
摘要: Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right, up or do 阅读全文
posted @ 2017-02-21 20:36 Strugglion 阅读(346) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Follow up: Wh 阅读全文
posted @ 2017-02-21 18:56 Strugglion 阅读(351) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number m 阅读全文
posted @ 2017-02-21 17:29 Strugglion 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 水塘抽样是一系列的随机算法,其目的在于从包含n个项目的集合S中选取k个样本,其中n为一很大或未知的数量,尤其适用于不能把所有n个项目都存放到主内存的情况。 在高德纳的计算机程序设计艺术中,有如下问题:可否在一未知大小的集合中,随机取出一元素?。或者是Google面试题: I have a linke 阅读全文
posted @ 2017-02-21 16:49 Strugglion 阅读(9266) 评论(2) 推荐(2) 编辑
摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2017-02-21 15:08 Strugglion 阅读(236) 评论(0) 推荐(0) 编辑
摘要: You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a conca 阅读全文
posted @ 2017-02-21 13:22 Strugglion 阅读(292) 评论(0) 推荐(0) 编辑