随笔分类 -  Leetcode

摘要:Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't 阅读全文
posted @ 2018-11-01 17:29 Veritas_des_Liberty 阅读(165) 评论(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]). F 阅读全文
posted @ 2018-11-01 16:46 Veritas_des_Liberty 阅读(141) 评论(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]). F 阅读全文
posted @ 2018-11-01 16:15 Veritas_des_Liberty 阅读(150) 评论(0) 推荐(0) 编辑
摘要: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 阅读(304) 评论(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 阅读(245) 评论(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 阅读(213) 评论(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 阅读(205) 评论(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 阅读(179) 评论(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 阅读(166) 评论(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 阅读(184) 评论(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 阅读(198) 评论(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 阅读(172) 评论(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 阅读(167) 评论(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 阅读(294) 评论(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 阅读(186) 评论(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 阅读(121) 评论(0) 推荐(0) 编辑