LeetCode 038 Count and Say】的更多相关文章

索引:[LeetCode] Leetcode 题解索引 (C++/Java/Python/Sql) Github: https://github.com/illuz/leetcode 038. Count and Say (Easy) 链接: 题目:https://leetcode.com/problems/Count-and-Say/ 代码(github):https://github.com/illuz/leetcode 题意: 数数.第一个是 1,第二个是数前一个数:1 个 1,就是 11…
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given…
题目要求:Count and Say The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2, then one 1"…
说来惭愧,已经四个月没有切 leetcode 上的题目了. 虽然工作中很少(几乎)没有用到什么高级算法,数据结构,但是我一直坚信 "任何语言都会过时,只有数据结构和算法才能永恒".leetcode 上的题目,截止目前切了 137 道(all solutions),只写过 6 篇题解,所以我会写题解的一般都是自认为还蛮有意思或者蛮典型的题目,就比如这道题. 题目链接:Count of Smaller Numbers After Self 这道题很有意思,给出一个数组,返回一个新的数组,新…
又是一道有意思的题目,Count of Range Sum.(PS:leetcode 我已经做了 190 道,欢迎围观全部题解 https://github.com/hanzichi/leetcode) 题意非常简单,给一个数组,如果该数组的一个子数组,元素之和大于等于给定的一个参数值(lower),小于等于一个给定的参数值(upper),那么这为一组解,求总共有几组解. 一个非常容易想到的解法是两层 for 循环遍历子数组首尾,加起来判断,时间复杂度 O(n^2). /** * @param…
https://leetcode.com/problems/count-of-range-sum/ Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (i ≤ j), incl…
Description: Count the number of prime numbers less than a non-negative number, n. 题目标签:Hash Table 题目给了我们一个n, 让我们找出比n小的 质数的数量. 因为这道题目有时间限定,不能用常规的方法. 首先建立一个boolean[] nums,里面初始值都是false,利用index 和 boolean 的对应,把所有prime number = false:non-prime number = tr…
说来惭愧,已经四个月没有切 leetcode 上的题目了. 虽然工作中很少(几乎)没有用到什么高级算法,数据结构,但是我一直坚信 "任何语言都会过时,只有数据结构和算法才能永恒".leetcode 上的题目,截止目前切了 137 道(all solutions),只写过 6 篇题解,所以我会写题解的一般都是自认为还蛮有意思或者蛮典型的题目,就比如这道题. 题目链接:Count of Smaller Numbers After Self 这道题很有意思,给出一个数组,返回一个新的数组,新…
题目链接: https://leetcode.com/problems/count-different-palindromic-subsequences/description/ 730.Count Different Palindromic Subsequences 题意 给你一个只包含a.b.c.d字符的字符串,总共有多少个不重复的回文子序列. 题解 容易想到这题可以用动态规划的方法来解决. 1.dp[l][r][k]表示区间[l,r]内,以字符k+'a'结尾的回文子序列个数. 当k+'a'…
题目链接:https://leetcode.com/problems/count-and-say/?tab=Description   1—>11—>21—>1211—>111221—>312211—>….   按照上面的规律进行求解出第n个字符串是什么.   规律:相连的数字有多少个然后添加上这个数字   参考代码:    package leetcode_50; /*** * * @author pengfei_zheng * 按照规律进行求解字符串 */ publ…