作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 除去2,3,5因子 日期 [LeetCode] 题目地址:https://leetcode.com/problems/ugly-number/ Total Accepted: 22335 Total Submissions: 67449 Difficulty: Easy 题目描述 Write a program to check whether a…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 异或 字典 日期 [LeetCode] 题目地址:https://leetcode.com/problems/single-number/ Total Accepted: 183838 Total Submissions: 348610 Difficulty: Easy 题目描述 Given a non-empty array of integers…
[LeetCode]306. Additive Number 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/additive-number/description/ 题目描述: Additive number is a string whose digits can form additive se…
[LeetCode]120. Triangle 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址https://leetcode.com/problems/triangle/description/ 题目描述: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjac…
[LeetCode]Largest Number 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/largest-number/#/description 题目描述: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], t…
题目描述: 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 example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7. Note that 1…
263. Ugly Number 注意:1.小于等于0都不属于丑数 2.while循环的判断不是num >= 0, 而是能被2 .3.5整除,即能被整除才去除这些数 class Solution { public: bool isUgly(int num) { ) return false; == ) num /= ; == ) num /= ; == ) num /= ; ? true : false; } }; 264. Ugly Number II 用一个数组去存第n个前面的所有整数,然后…
lc 263 Ugly Number lc 263 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 example, 6, 8 are ugly while 14 is not ugly since it includes ano…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 题目地址:https://leetcode.com/problems/distribute-candies/#/description 题目描述 Given an integer array with even length, where different numbers in this array repre…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 [LeetCode] 题目地址:https://leetcode.com/problems/ransom-note/ Difficulty: Easy 题目描述 Given an arbitrary ransom note string and another string containing letters…
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. Example 1: Input: 6 Output: true Explanation: 6 = 2 × 3 Example 2: Input: 8 Output: true Explanation: 8 = 2…
Problem: 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 example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7. Note tha…
Ugly Number的质因数仅为2,3,5 将输入的数分别除以2,3,5直到不能除,看是否为1,为1的是Ugly Number,其他则不是. class Solution { public: bool isUgly(int num) { ) return false; ] ={,,}; ; i < ; ++i){ ){ num /= prime[i]; } } ; } };…
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 example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7. Note that 1 is ty…
只要存在一种因数分解后,其因子是2,3,5中的一种或多种,就算是ugly数字. 思路: 以2/3/5作为除数除后,最后结果等于1的就是ugly数字 Runtime: 4 ms, faster than 98.64% of C++ online submissions for Ugly Number. class Solution { public: bool isUgly(int num) { == && num > ) num /= ; == && num >…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/perfect-number/#/description 题目描述 We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 设置当前节点的值为下一个 日期 [LeetCode] 题目地址:https://leetcode.com/problems/delete-node-in-a-linked-list/ Total Accepted: 78258 Total Submissions: 179086 Difficulty: Easy 题目描述 Write a functio…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:首尾指针 方法二:头部双指针+双循环 方法三:指针指向第一个0的位置 日期 题目地址:https://leetcode.com/problems/move-zeroes/ Total Accepted: 77443 Total Submissions: 175420 Difficulty: Easy 题目描述 Given an array n…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:Java解法,HashSet 方法二:Python解法,set 日期 [LeetCode] 题目地址:https://leetcode.com/problems/intersection-of-two-arrays/ Difficulty: Easy 题目描述 Given two arrays, write a function to com…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 遍历子串 日期 [LeetCode] 题目地址:https://leetcode.com/problems/repeated-substring-pattern/ Difficulty: Easy 题目描述 Given a non-empty string check if it can be constructed by taking a subs…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 数学 日期 题目地址:https://leetcode.com/problems/reach-a-number/description/ 题目描述 You are standing at position 0 on an infinite number line. There is a goal at position target. On each…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 替换最大值数组 使用set 三个变量 日期 题目地址:https://leetcode.com/problems/third-maximum-number/description/ 题目描述 Given a non-empty array of integers, return the third maximum number in this arr…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/valid-triangle-number/description/ 题目描述: Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array t…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 保存已经访问过的数字 链表成环 二分查找 日期 题目地址:https://leetcode.com/problems/find-the-duplicate-number/description/ 题目描述 Given an array nums containing n + 1 integers where each integer is betwe…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS 日期 题目地址:https://leetcode.com/problems/minesweeper/description/ 题目描述 Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing th…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 回溯法 日期 题目地址:https://leetcode.com/problems/subsets/description/ 题目描述 Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution se…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 方法一:库函数 方法二:递归 方法三:回溯法 日期 题目地址:https://leetcode.com/problems/permutations/description/ 题目描述 Given a collection of distinct numbers, return all possible permutations. For example, [1,…
题目要求 The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, F(0) = 0,   F(1) = 1​ F(N) = F(N - 1) + F(N - 2), for N > 1.…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 栈 递归 数组 日期 题目地址:https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/ 题目描述 输入一个链表的头节点,从尾到头反过来返回每个节点的值(用数组返回). 示例 1: 输入:head = [1,3,2] 输出:[2,3,1] 限制: 0 <= 链表长度 <=…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/h-index/description/ 题目描述: Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's…