随笔分类 -  LeetCode

上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 61 下一页
摘要:Shuffle a set of numbers without duplicates. Example: 这道题让我们给数组洗牌,也就是随机打乱顺序,那么由于之前那道题Linked List Random Node我们接触到了水塘抽样Reservoir Sampling的思想,这道题实际上这道题也 阅读全文
posted @ 2016-08-18 11:42 Grandyang 阅读(19834) 评论(17) 推荐(0) 编辑
摘要:Given a nested list of integers represented as a string, implement a parser to deserialize it. Each element is either an integer, or a list -- whose e 阅读全文
posted @ 2016-08-14 23:49 Grandyang 阅读(10969) 评论(4) 推荐(2) 编辑
摘要:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the rans 阅读全文
posted @ 2016-08-12 11:35 Grandyang 阅读(6272) 评论(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. Implement the 阅读全文
posted @ 2016-08-11 10:17 Grandyang 阅读(15443) 评论(7) 推荐(1) 编辑
摘要:Design a data structure that supports all following operations in average O(1) time. Note: Duplicate elements are allowed. insert(val): Inserts an ite 阅读全文
posted @ 2016-08-10 11:43 Grandyang 阅读(10098) 评论(8) 推荐(1) 编辑
摘要:Design a data structure that supports all following operations in average O(1) time. Example: 这道题让我们在常数时间范围内实现插入删除和获得随机数操作,如果这道题没有常数时间的限制,那么将会是一道非常简单的 阅读全文
posted @ 2016-08-05 12:40 Grandyang 阅读(21522) 评论(13) 推荐(3) 编辑
摘要:Design a Phone Directory which supports the following operations: Example: 又是一道设计题,让我们设计一个电话目录管理系统,可以分配电话号码,查询某一个号码是否已经被使用,释放一个号码。既然要分配号码,肯定需要一个数组 num 阅读全文
posted @ 2016-08-04 03:13 Grandyang 阅读(11316) 评论(5) 推荐(0) 编辑
摘要:Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix. Note that it is 阅读全文
posted @ 2016-08-02 06:46 Grandyang 阅读(36847) 评论(18) 推荐(0) 编辑
摘要:Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target. The answer is  阅读全文
posted @ 2016-07-25 23:19 Grandyang 阅读(23857) 评论(19) 推荐(2) 编辑
摘要:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文
posted @ 2016-07-22 23:57 Grandyang 阅读(11614) 评论(7) 推荐(1) 编辑
摘要:We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2016-07-16 23:48 Grandyang 阅读(22611) 评论(10) 推荐(0) 编辑
摘要:We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2016-07-13 12:40 Grandyang 阅读(12117) 评论(8) 推荐(0) 编辑
摘要:You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u, v) which consists of one element from t 阅读全文
posted @ 2016-07-08 13:39 Grandyang 阅读(17483) 评论(2) 推荐(0) 编辑
摘要:Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array. Exampl 阅读全文
posted @ 2016-07-07 23:51 Grandyang 阅读(12047) 评论(5) 推荐(2) 编辑
摘要:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: In 阅读全文
posted @ 2016-07-01 08:43 Grandyang 阅读(23514) 评论(10) 推荐(2) 编辑
摘要:You are given two jugs with capacities jug1Capacity and jug2Capacity liters. There is an infinite amount of water supply available. Determine whether 阅读全文
posted @ 2016-06-30 08:55 Grandyang 阅读(14328) 评论(12) 推荐(0) 编辑
摘要:Assume you have an array of length n initialized with all 0's and are given k update operations. Each operation is represented as a triplet: [startInd 阅读全文
posted @ 2016-06-30 08:14 Grandyang 阅读(13258) 评论(3) 推荐(0) 编辑
摘要:Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer. You may assume the integer do not conta 阅读全文
posted @ 2016-06-29 12:01 Grandyang 阅读(11989) 评论(2) 推荐(1) 编辑
摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or 阅读全文
posted @ 2016-06-28 22:23 Grandyang 阅读(17687) 评论(7) 推荐(0) 编辑
摘要:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio 阅读全文
posted @ 2016-06-27 09:53 Grandyang 阅读(15326) 评论(7) 推荐(1) 编辑

上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 61 下一页
Fork me on GitHub