摘要: 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 阅读(298) 评论(0) 推荐(0) 编辑
摘要: 水塘抽样是一系列的随机算法,其目的在于从包含n个项目的集合S中选取k个样本,其中n为一很大或未知的数量,尤其适用于不能把所有n个项目都存放到主内存的情况。 在高德纳的计算机程序设计艺术中,有如下问题:可否在一未知大小的集合中,随机取出一元素?。或者是Google面试题: I have a linke 阅读全文
posted @ 2017-02-21 16:49 Strugglion 阅读(9316) 评论(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 阅读(238) 评论(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 阅读(298) 评论(0) 推荐(0) 编辑
摘要: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 解法: 这道题让我们求两数相除,而且规定我们不能用乘法,除法和取余操作。 采 阅读全文
posted @ 2017-02-20 22:24 Strugglion 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 解法: 这道题让我们在一个字符串中找另一个字符串 阅读全文
posted @ 2017-02-20 18:01 Strugglion 阅读(518) 评论(0) 推荐(0) 编辑
摘要: Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2017-02-20 17:43 Strugglion 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文
posted @ 2017-02-20 16:47 Strugglion 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to 阅读全文
posted @ 2017-02-20 16:28 Strugglion 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your 阅读全文
posted @ 2017-02-20 14:27 Strugglion 阅读(150) 评论(0) 推荐(0) 编辑