随笔分类 -  Sort

摘要:题目: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 阅读全文 »
posted @ 2021-05-03 21:35 Veritas_des_Liberty 阅读(258) 评论(0) 推荐(1) 编辑
摘要: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 阅读全文 »
posted @ 2019-05-01 11:07 Veritas_des_Liberty 阅读(356) 评论(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 阅读(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 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) 编辑

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