题目描述:
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
You may assume that the array is non-empty and the majority element always exist ...
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
You may assume that the array is non-empty and the majority element always exist ...
Given a non-zero positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB
给定一个正整数,返回其在Excel表格中对应的列标题 ...
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
If the fractional part is repeating, enclose the repeating part in parentheses.
For example,
Compare two version numbers version1 and version2.
If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The ...
基数排序(Radix Sort)、桶排序(Bucket Sort)和计数排序(Counting Sort)都是非比较排序算法。也就是说,它们并不是通过比较元素之间的大小关系来进行排序的。
首先,让我们看看三种排序算法的时间复杂度:
基数排序:O(dn) (d次调用桶排序),空间复杂度 O(k) (稍后详解)
桶排序:O(n)时间复杂度,O(n)空间复杂度
计数排序:O(n)时间复杂度,O(k)空间复杂度,每一个元素都是整数,并且位于0到k - 1之间