01 2018 档案

摘要:You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the sto... 阅读全文
posted @ 2018-01-29 22:40 xiejunzhao 阅读(935) 评论(0) 推荐(0) 编辑
摘要:Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Example 1:Input: k = 3, ... 阅读全文
posted @ 2018-01-29 22:39 xiejunzhao 阅读(149) 评论(0) 推荐(0) 编辑
摘要:Shuffle a set of numbers without duplicates. Example:// Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums); // Shuffle the array [1,2,3] and return its r... 阅读全文
posted @ 2018-01-23 21:52 xiejunzhao 阅读(166) 评论(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: What if the linked list is extremely large and its le... 阅读全文
posted @ 2018-01-23 21:51 xiejunzhao 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ "((()))", "(()())", "(())()", "()(())",... 阅读全文
posted @ 2018-01-23 21:50 xiejunzhao 阅读(154) 评论(0) 推荐(0) 编辑
摘要:A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.Example 1:Input: matrix = [[1,2,3... 阅读全文
posted @ 2018-01-22 23:26 xiejunzhao 阅读(194) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.Find the maximum result of ai XOR aj, where 0 ≤ i, j < n.Could you do this in O(n) runtime?Example:Input: [3, 10, 5, 25, 2,... 阅读全文
posted @ 2018-01-22 23:26 xiejunzhao 阅读(154) 评论(0) 推荐(0) 编辑
摘要:The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Now your job is to find the total Hamming distance between all pairs of the given... 阅读全文
posted @ 2018-01-19 23:07 xiejunzhao 阅读(141) 评论(0) 推荐(0) 编辑
摘要:You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow another pair (a, b) if and only if b [3,4] Note:T... 阅读全文
posted @ 2018-01-19 23:06 xiejunzhao 阅读(202) 评论(0) 推荐(0) 编辑
摘要:There is a room with n lights which are turned on initially and 4 buttons on the wall. After performing exactly m unknown operations towards buttons, you need to return how many different kinds of st... 阅读全文
posted @ 2018-01-19 23:05 xiejunzhao 阅读(181) 评论(0) 推荐(0) 编辑
摘要:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially filled sudoku which... 阅读全文
posted @ 2018-01-19 23:04 xiejunzhao 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) I... 阅读全文
posted @ 2018-01-17 21:36 xiejunzhao 阅读(137) 评论(0) 推荐(0) 编辑
摘要:Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1:Input: s1 = "sea", s2 = "eat" Output: 231 Explanation: Deleting "s" from "sea" adds the AS... 阅读全文
posted @ 2018-01-17 21:36 xiejunzhao 阅读(152) 评论(0) 推荐(0) 编辑
摘要:A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing th... 阅读全文
posted @ 2018-01-15 22:41 xiejunzhao 阅读(126) 评论(0) 推荐(0) 编辑
摘要:Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation.(Recall that the number of set bits an integer ha... 阅读全文
posted @ 2018-01-15 22:41 xiejunzhao 阅读(315) 评论(0) 推荐(0) 编辑
摘要:Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. We want to find an index mapping P, from A to B. A mapping P[i] ... 阅读全文
posted @ 2018-01-10 22:58 xiejunzhao 阅读(316) 评论(0) 推荐(0) 编辑
摘要:Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is [a1, a2, a3, ... ... 阅读全文
posted @ 2018-01-10 22:58 xiejunzhao 阅读(184) 评论(0) 推荐(0) 编辑
摘要:Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same length ... 阅读全文
posted @ 2018-01-07 10:25 xiejunzhao 阅读(133) 评论(0) 推荐(0) 编辑
摘要:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, th... 阅读全文
posted @ 2018-01-07 10:25 xiejunzhao 阅读(199) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示