随笔分类 - Sort
发表于 2021-05-03 21:35阅读:258评论:0推荐:1
摘要:题目:912. 排序数组 给你一个整数数组 nums,请你将该数组升序排列。 示例 1: 输入:nums = [5,2,3,1]输出:[1,2,3,5]示例 2: 输入:nums = [5,1,1,2,0,0]输出:[0,0,1,1,2,5] 提示: 1 <= nums.length <= 5000
阅读全文 »
发表于 2019-05-01 11:07阅读:356评论:0推荐:0
摘要:You have an array of logs. Each log is a space delimited string of words. For each log, the first word in each log is an alphanumeric identifier. Then
阅读全文 »
发表于 2018-10-31 18:32阅读:309评论: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
阅读全文 »
发表于 2018-10-31 16:55阅读:247评论: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
阅读全文 »
发表于 2018-10-30 22:39阅读:219评论: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.
阅读全文 »
发表于 2018-10-30 22:24阅读: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: [9,4] Exam
阅读全文 »
发表于 2018-10-30 22:15阅读:183评论: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
阅读全文 »
发表于 2018-10-30 21:53阅读:168评论: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
阅读全文 »
发表于 2018-10-30 21:41阅读:189评论: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
阅读全文 »
发表于 2018-10-30 15:53阅读:147评论: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
阅读全文 »
发表于 2018-10-30 09:47阅读:267评论: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: [
阅读全文 »
发表于 2018-10-30 09:26阅读:200评论: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
阅读全文 »
发表于 2018-10-29 19:05阅读:174评论: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
阅读全文 »
发表于 2018-10-29 15:13阅读:150评论: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
阅读全文 »
发表于 2018-10-16 16:59阅读:187评论:0推荐:0
摘要:Given an unsorted integer array, find the smallest missing positive integer. Given an unsorted integer array, find the smallest missing positive integ
阅读全文 »