lintcode :Count and Say 报数】的更多相关文章

题目: 报数 报数指的是,按照其中的整数的顺序进行报数,然后得到下一个数.如下所示: 1, 11, 21, 1211, 111221, ... 1 读作 "one 1" -> 11. 11 读作 "two 1s" -> 21. 21 读作 "one 2, then one 1" -> 1211. 给定一个整数 n, 返回 第 n 个顺序. 样例 给定 n = 5, 返回 "111221". 注意 整数的顺序将…
这道题是LeetCode里的第38道题. 题目要求: 报数序列是一个整数序列,按照其中的整数的顺序进行报数,得到下一个数.其前五项如下: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 被读作  "one 1"  ("一个一") , 即 11.11 被读作 "two 1s" ("两个一"), 即 21.21 被读作 "one 2",  "one 1" (&quo…
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…
Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 10000) and an query list. For each query, give you an integer, return the number of element in the array that are smaller than the given integer. Have…
Warning: input could be > 10000... Solution by segment tree: struct Node { Node(), left(nullptr), right(nullptr) {}; int start; int end; int cnt; // Node *left; Node *right; }; class Solution { Node *pRoot; void update(int v) { Node *p = pRoot; while…
[抄题]: 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.Give…
知识点 1. 整数的二进制表示法 2. 十进制和二进制的转换 http://baike.baidu.com/view/1426817.htm 3. 负整数的表示(原码,补码,反码) http://www.cnblogs.com/zhangziqiu/archive/2011/03/30/ComputerCode.html 4. 位操作 Bit Operation 左移 Left Shift      << 右移 Right Shift    >> 与 And   & 或  …
C++ class Solution { public: /** * @param n the nth * @return the nth sequence */ string countAndSay(int n) { // Write your code here == n) { return ""; } "; ; i < n; i++) {//从第2个(i=1)开始 ]; string cur = ""; ; ; j < pre.size(…
Almost identical to LintCode "Count of Smaller Number before Self". Corner case needs to be taken care of. class Solution { ////////////////// // Fenwick Tree // vector<long long> ft; void update(int i, long long x) { ) { ft[] ++; return;…
数组.排序 关于排序 :参考 关于数组: 参考 求a[i][j]行与列的和然后求平均值 参考 二维数组使用指针的表示方法  参考 字符串数组:char  name [5][20] ={ {} , {} ,{} ,{} ,{} };  或者 char name[5][20] = { "xxx", "xxx", "xxx",  "xxx", "xxx"}; 二维数组就是一维数组的组合,数组维度大于2就是多维数组…