文章 2023-01-11 来自:开发者社区

LeetCode 75 Sort Colors 颜色分类(荷兰国旗)

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 order red, white and blue.Here, we will use the int....

文章 2023-01-05 来自:开发者社区

LeetCode 148. Sort List

DescriptionSort a linked list in O(n log n) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -1-&a...

LeetCode 148. Sort List
文章 2023-01-05 来自:开发者社区

LeetCode 75. Sort Colors

DescriptionGiven 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 order red, white and blue.Here, we will ....

LeetCode 75. Sort Colors
文章 2022-12-29 来自:开发者社区

LeetCode 905. Sort Array By Parity

905. Sort Array By ParityGiven an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.You may return any answer array tha....

文章 2022-04-28 来自:开发者社区

【LeetCode1122】数组的相对排序(哈希or自定义sort)

一、题目二、方法一:哈希没错,,简单题,就是说将arr1中有arr2的元素,则按照arr2的元素先排列(特别注意:这里的arr2的元素都是不同的,但是arr1中是可以元素重复的),然后arr1中不是arr2的元素则被丢到arr1的尾巴。可以用哈希,用mp1记录arr1数组每种数字的出现次数,mp2记录arr2数组的是否出现,接着就是上面说的逻辑,,就是脑子清醒点,mp1[arr2[i]]这种东西....

【LeetCode1122】数组的相对排序(哈希or自定义sort)
文章 2017-12-15 来自:开发者社区

[LeetCode] Wiggle Sort II 摆动排序

Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example: (1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1,...

文章 2017-12-15 来自:开发者社区

[LeetCode] Wiggle Sort 摆动排序

Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, ....

文章 2017-12-13 来自:开发者社区

[LeetCode] Sort Transformed Array 变换数组排序

Given a sorted array of integers nums and integer values a, b and c. Apply a function of the form f(x) = ax2 + bx + c to each elem...

文章 2017-12-10 来自:开发者社区

[LeetCode] Sort Characters By Frequency 根据字符出现频率排序

Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' m...

文章 2017-12-04 来自:开发者社区

[LeetCode] Sort List 链表排序

Sort a linked list in O(n log n) time using constant space complexity. 常见排序方法有很多,插入排序,选择排序,堆排序,快速排序,冒泡排序,归并排序,桶排序等等。。它们的时间复杂度不尽相同,而这里题目限定了时间必须为O(nlgn),符合要求只有快速排序,归并排序,堆排序,而根据单链表的特点,最适于用...

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

算法编程

开发者社区在线编程频道官方技术圈。包含算法资源更新,周赛动态,每日一题互动。

+关注