10 2018 档案

摘要:Given a blacklist B containing unique integers from [0, N), write a function to return a uniform random integer from [0, N) which is NOT in B. Optimiz 阅读全文 »
posted @ 2018-10-31 18:32 Veritas_des_Liberty 阅读(309) 评论(0) 推荐(0) 编辑
摘要:Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same. If possible, output 阅读全文 »
posted @ 2018-10-31 16:55 Veritas_des_Liberty 阅读(247) 评论(0) 推荐(0) 编辑
摘要:Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. 阅读全文 »
posted @ 2018-10-30 22:39 Veritas_des_Liberty 阅读(219) 评论(0) 推荐(0) 编辑
摘要:Given two arrays, write a function to compute their intersection. Example 1: Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [9,4] Exam 阅读全文 »
posted @ 2018-10-30 22:24 Veritas_des_Liberty 阅读(214) 评论(0) 推荐(0) 编辑
摘要:Given two arrays, write a function to compute their intersection. Example 1: Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [4,9] Exam 阅读全文 »
posted @ 2018-10-30 22:15 Veritas_des_Liberty 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Example 2: Note:You may assume the string contains only 阅读全文 »
posted @ 2018-10-30 21:53 Veritas_des_Liberty 阅读(168) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example 1: Example 2: Note:You may assume all input has v 阅读全文 »
posted @ 2018-10-30 21:41 Veritas_des_Liberty 阅读(189) 评论(0) 推荐(0) 编辑
摘要:Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. According 阅读全文 »
posted @ 2018-10-30 15:53 Veritas_des_Liberty 阅读(147) 评论(0) 推荐(0) 编辑
摘要:Given a list of non negative integers, arrange them such that they form the largest number. Example 1: Input: [10,2] Output: "210" Example 2: Input: [ 阅读全文 »
posted @ 2018-10-30 09:47 Veritas_des_Liberty 阅读(267) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Return 0 if the array contains less than 2 el 阅读全文 »
posted @ 2018-10-30 09:26 Veritas_des_Liberty 阅读(200) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list in O(n log n) time using constant space complexity. Example 1: Example 2: AC code: time(O(nlongn) space(O(logn)) Runtime: 28 ms, fa 阅读全文 »
posted @ 2018-10-29 19:05 Veritas_des_Liberty 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first elem 阅读全文 »
posted @ 2018-10-29 15:13 Veritas_des_Liberty 阅读(150) 评论(0) 推荐(0) 编辑
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: AC code: Runtime: 4 ms, faster tha 阅读全文 »
posted @ 2018-10-28 21:45 Veritas_des_Liberty 阅读(195) 评论(0) 推荐(0) 编辑
摘要:Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: AC code: Runtime: 0 ms, faster than 100.00%  阅读全文 »
posted @ 2018-10-28 21:00 Veritas_des_Liberty 阅读(170) 评论(0) 推荐(0) 编辑
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given a non-empty strin 阅读全文 »
posted @ 2018-10-28 17:58 Veritas_des_Liberty 阅读(200) 评论(0) 推荐(0) 编辑
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta 阅读全文 »
posted @ 2018-10-28 16:49 Veritas_des_Liberty 阅读(297) 评论(0) 推荐(0) 编辑
摘要:The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total num 阅读全文 »
posted @ 2018-10-27 21:41 Veritas_des_Liberty 阅读(187) 评论(0) 推荐(0) 编辑
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and num 阅读全文 »
posted @ 2018-10-26 21:43 Veritas_des_Liberty 阅读(123) 评论(0) 推荐(0) 编辑
摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representati 阅读全文 »
posted @ 2018-10-26 21:24 Veritas_des_Liberty 阅读(189) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文 »
posted @ 2018-10-25 18:50 Veritas_des_Liberty 阅读(171) 评论(0) 推荐(0) 编辑
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example: AC code: Runtime: 12 ms 阅读全文 »
posted @ 2018-10-25 16:31 Veritas_des_Liberty 阅读(154) 评论(0) 推荐(0) 编辑
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文 »
posted @ 2018-10-25 12:20 Veritas_des_Liberty 阅读(169) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Example 2: my code: Runtime: 12 ms, faster than  阅读全文 »
posted @ 2018-10-25 10:52 Veritas_des_Liberty 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Example 2: 阅读全文 »
posted @ 2018-10-24 18:07 Veritas_des_Liberty 阅读(196) 评论(0) 推荐(0) 编辑
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). Y 阅读全文 »
posted @ 2018-10-24 17:36 Veritas_des_Liberty 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra 阅读全文 »
posted @ 2018-10-24 16:39 Veritas_des_Liberty 阅读(186) 评论(0) 推荐(0) 编辑
摘要:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文 »
posted @ 2018-10-24 15:47 Veritas_des_Liberty 阅读(224) 评论(0) 推荐(0) 编辑
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl 阅读全文 »
posted @ 2018-10-24 12:02 Veritas_des_Liberty 阅读(168) 评论(0) 推荐(0) 编辑
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: AC code: Runtime: 88 ms, faster than 42.24% of C++  阅读全文 »
posted @ 2018-10-24 11:03 Veritas_des_Liberty 阅读(277) 评论(0) 推荐(0) 编辑
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Input: S = "ADOB 阅读全文 »
posted @ 2018-10-23 22:17 Veritas_des_Liberty 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or 阅读全文 »
posted @ 2018-10-23 21:20 Veritas_des_Liberty 阅读(170) 评论(0) 推荐(0) 编辑
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文 »
posted @ 2018-10-23 21:09 Veritas_des_Liberty 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: 阅读全文 »
posted @ 2018-10-23 20:39 Veritas_des_Liberty 阅读(176) 评论(0) 推荐(0) 编辑
摘要:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文 »
posted @ 2018-10-22 22:23 Veritas_des_Liberty 阅读(167) 评论(0) 推荐(0) 编辑
摘要:Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"path = "/a/../../ 阅读全文 »
posted @ 2018-10-22 21:37 Veritas_des_Liberty 阅读(207) 评论(0) 推荐(0) 编辑
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文 »
posted @ 2018-10-22 18:47 Veritas_des_Liberty 阅读(175) 评论(0) 推荐(0) 编辑
摘要:Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an in 阅读全文 »
posted @ 2018-10-22 18:30 Veritas_des_Liberty 阅读(238) 评论(0) 推荐(0) 编辑
摘要:Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justif 阅读全文 »
posted @ 2018-10-22 18:10 Veritas_des_Liberty 阅读(154) 评论(0) 推荐(0) 编辑
摘要:Validate if a given string can be interpreted as a decimal number. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true" 阅读全文 »
posted @ 2018-10-21 19:27 Veritas_des_Liberty 阅读(193) 评论(0) 推荐(0) 编辑
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文 »
posted @ 2018-10-21 13:58 Veritas_des_Liberty 阅读(156) 评论(0) 推荐(0) 编辑
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文 »
posted @ 2018-10-21 13:40 Veritas_des_Liberty 阅读(173) 评论(0) 推荐(0) 编辑
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文 »
posted @ 2018-10-20 22:24 Veritas_des_Liberty 阅读(192) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Input: 1->2->3->4->5->NULL, k = 2 Output: 4->5->1-> 阅读全文 »
posted @ 2018-10-20 21:36 Veritas_des_Liberty 阅读(179) 评论(0) 推荐(0) 编辑
摘要:The set [1,2,3,...,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following seque 阅读全文 »
posted @ 2018-10-20 10:35 Veritas_des_Liberty 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. Example: AC code: Runtime: 0 ms, faster than 1 阅读全文 »
posted @ 2018-10-19 21:04 Veritas_des_Liberty 阅读(161) 评论(0) 推荐(0) 编辑
摘要:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文 »
posted @ 2018-10-19 20:36 Veritas_des_Liberty 阅读(158) 评论(0) 推荐(0) 编辑
摘要:Given a collection of intervals, merge all overlapping intervals. Example 1: Example 2: AC code: 阅读全文 »
posted @ 2018-10-19 20:27 Veritas_des_Liberty 阅读(162) 评论(0) 推荐(0) 编辑
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word 阅读全文 »
posted @ 2018-10-19 16:00 Veritas_des_Liberty 阅读(130) 评论(0) 推荐(0) 编辑
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文 »
posted @ 2018-10-19 09:40 Veritas_des_Liberty 阅读(152) 评论(0) 推荐(0) 编辑
摘要:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Inpu 阅读全文 »
posted @ 2018-10-18 22:33 Veritas_des_Liberty 阅读(172) 评论(0) 推荐(0) 编辑
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the 阅读全文 »
posted @ 2018-10-18 22:16 Veritas_des_Liberty 阅读(173) 评论(0) 推荐(0) 编辑
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all 阅读全文 »
posted @ 2018-10-18 22:11 Veritas_des_Liberty 阅读(150) 评论(0) 推荐(0) 编辑
摘要:Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Example 2: Example 3: Note: -100.0 < x < 100.0 n is a 32-bit signed int 阅读全文 »
posted @ 2018-10-17 22:00 Veritas_des_Liberty 阅读(224) 评论(0) 推荐(0) 编辑
摘要:Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat", 阅读全文 »
posted @ 2018-10-17 21:38 Veritas_des_Liberty 阅读(162) 评论(0) 推荐(0) 编辑
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which 阅读全文 »
posted @ 2018-10-17 20:01 Veritas_des_Liberty 阅读(178) 评论(0) 推荐(0) 编辑
摘要:Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example: AC code: Runtime: 28 ms, faster than 46 阅读全文 »
posted @ 2018-10-17 19:46 Veritas_des_Liberty 阅读(185) 评论(0) 推荐(0) 编辑
摘要:Given a collection of distinct integers, return all possible permutations. Example: Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1, 阅读全文 »
posted @ 2018-10-17 11:50 Veritas_des_Liberty 阅读(182) 评论(0) 推荐(0) 编辑
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文 »
posted @ 2018-10-17 11:17 Veritas_des_Liberty 阅读(175) 评论(0) 推荐(0) 编辑
摘要:Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' M 阅读全文 »
posted @ 2018-10-16 20:37 Veritas_des_Liberty 阅读(172) 评论(0) 推荐(0) 编辑
摘要:Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Example 1: Ex 阅读全文 »
posted @ 2018-10-16 20:03 Veritas_des_Liberty 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文 »
posted @ 2018-10-16 17:35 Veritas_des_Liberty 阅读(173) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted integer array, find the smallest missing positive integer. Given an unsorted integer array, find the smallest missing positive integ 阅读全文 »
posted @ 2018-10-16 16:59 Veritas_des_Liberty 阅读(187) 评论(0) 推荐(0) 编辑
摘要:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numb 阅读全文 »
posted @ 2018-10-15 22:00 Veritas_des_Liberty 阅读(184) 评论(0) 推荐(0) 编辑
摘要:Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the 阅读全文 »
posted @ 2018-10-15 21:30 Veritas_des_Liberty 阅读(196) 评论(0) 推荐(0) 编辑
摘要:The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "on 阅读全文 »
posted @ 2018-10-14 17:38 Veritas_des_Liberty 阅读(217) 评论(0) 推荐(0) 编辑
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9 阅读全文 »
posted @ 2018-10-14 16:47 Veritas_des_Liberty 阅读(197) 评论(0) 推荐(0) 编辑
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). Y 阅读全文 »
posted @ 2018-10-11 22:28 Veritas_des_Liberty 阅读(195) 评论(0) 推荐(0) 编辑
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Exampl 阅读全文 »
posted @ 2018-10-10 23:18 Veritas_des_Liberty 阅读(185) 评论(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 @ 2018-10-09 23:44 Veritas_des_Liberty 阅读(197) 评论(0) 推荐(0) 编辑
摘要:Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list t 阅读全文 »
posted @ 2018-10-09 08:35 Veritas_des_Liberty 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return the quotient after dividi 阅读全文 »
posted @ 2018-10-08 21:57 Veritas_des_Liberty 阅读(184) 评论(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 @ 2018-10-07 22:39 Veritas_des_Liberty 阅读(200) 评论(0) 推荐(0) 编辑
摘要:origianl For the past few days, I’ve been reading various explanations of the Knuth-Morris-Pratt string searching algorithms. For some reason, none of 阅读全文 »
posted @ 2018-10-06 22:03 Veritas_des_Liberty 阅读(262) 评论(0) 推荐(0) 编辑
摘要:Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Example 2: Cla 阅读全文 »
posted @ 2018-10-06 21:38 Veritas_des_Liberty 阅读(181) 评论(0) 推荐(0) 编辑
摘要:Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another ar 阅读全文 »
posted @ 2018-10-06 21:17 Veritas_des_Liberty 阅读(204) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra spa 阅读全文 »
posted @ 2018-10-06 21:12 Veritas_des_Liberty 阅读(179) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, swap every two adjacent nodes and return its head. Example: Note: Your algorithm should use only constant extra space. You may no 阅读全文 »
posted @ 2018-10-05 21:52 Veritas_des_Liberty 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: AC code: Runtime: 56 ms, faster than 26.25 阅读全文 »
posted @ 2018-10-05 21:07 Veritas_des_Liberty 阅读(119) 评论(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: A 阅读全文 »
posted @ 2018-10-04 10:43 Veritas_des_Liberty 阅读(185) 评论(0) 推荐(0) 编辑
摘要:Lists将元素按顺序储存在链表中. 与 向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢. assign() 给list赋值 back() 返回最后一个元素 begin() 返回指向第一个元素的迭代器 clear() 删除所有元素 empty() 如果list是空的则返回 阅读全文 »
posted @ 2018-10-04 09:57 Veritas_des_Liberty 阅读(207) 评论(0) 推荐(0) 编辑
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: 阅读全文 »
posted @ 2018-10-04 09:54 Veritas_des_Liberty 阅读(147) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, remove the n-th node from the end of list and return its head. Example: Note: Given n will always be valid. Follow up: Could you 阅读全文 »
posted @ 2018-10-03 22:08 Veritas_des_Liberty 阅读(147) 评论(0) 推荐(0) 编辑
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to le 阅读全文 »
posted @ 2018-10-03 21:11 Veritas_des_Liberty 阅读(218) 评论(0) 推荐(0) 编辑
摘要:Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique q 阅读全文 »
posted @ 2018-10-02 22:41 Veritas_des_Liberty 阅读(143) 评论(0) 推荐(0) 编辑
摘要:Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the thr 阅读全文 »
posted @ 2018-10-02 22:02 Veritas_des_Liberty 阅读(150) 评论(0) 推荐(0) 编辑

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