[leetcode/lintcode 题解] 阿里算法面试真题:丑数 II · Ugly Number II

[leetcode/lintcode 题解] 阿里算法面试真题:丑数 II · Ugly Number II

描述设计一个算法,找出只含素因子2,3,5 的第 n 小的数。符合条件的数如:1, 2, 3, 4, 5, 6, 8, 9, 10, 12...:我们可以认为 1 也是一个丑数。在线评测地址:领扣题库官网样例1 输入:9 输出:10样例2 输入:1 输出:1解题思路1:最小堆很容易想到的方法是:从1...

[LintCode] Number of Islands(岛屿个数)

描述 给一个01矩阵,求不同的岛屿的个数。 0代表海,1代表岛,如果两个1相邻,那么这两个1属于同一个岛。我们只考虑上下左右为相邻。 样例 在矩阵: [ [1, 1, 0, 0, 0], [0, 1, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0...

[LintCode] Super Ugly Number 超级丑陋数

Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes ...

[LintCode] Ugly Number 丑陋数

Write a program to check whether a given number is an ugly number`. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For ex...

[LintCode] Happy Number 快乐数

Write an algorithm to determine if a number is happy. A happy number is a number defined by the following process: Starting with any positive integer,...

[LintCode] Create Maximum Number 创建最大数

Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two....

[LintCode] Number of Islands 岛屿的数量

Given a boolean 2D matrix, find the number of islands.  Notice 0 is represented as the sea, 1 is represented as the island. If two 1 is adjacent,...

[LintCode] Letter Combinations of a Phone Number 电话号码的字母组合

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telepho...

[LintCode] Valid Number 验证数字

Validate if a given string is numeric. Have you met this question in a real interview?&nbsp; Yes Example "0"&nbsp;=&gt;&nbsp;true " 0.1 "&nbsp;=&gt;&n...

[LintCode] Kth Smallest Number in Sorted Matrix 有序矩阵中第K小的数字

Find the kth smallest number in at row and column sorted matrix. Have you met this question in a real interview?  Yes Example Given k = ...

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