• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
us4ever
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

2017年1月17日

leetcode 448. Find All Numbers Disappeared in an Array
摘要: solution: The basic idea here is to label all appeared numbers in the array. Since we don't want to introduce extra space and given all numbers are po 阅读全文
posted @ 2017-01-17 21:22 us4ever 阅读(145) 评论(0) 推荐(0)
 
关于c++ bitset
摘要: bitset 的下标计数问题 example: 运行这个程序可以看到虽然bitset的pattern在屏幕上是从右边开始的,也就是5的bitset是0000...00101 但是在下标上,bs[0]=1, bs[1]=0, bs[2]=1, ... 而不是bs[31]=1, bs[30]=0, bs 阅读全文
posted @ 2017-01-17 19:45 us4ever 阅读(201) 评论(0) 推荐(0)
 
 

2016年4月8日

C++:关于vector
摘要: 1. vector的初始化。 C++ primer列出了几种初始化vector对象的方式: ①vector<T> v1; ②vector<T> v2(v1); v2初始化为v1的一个副本。 ③vector<T> v3(n,i); v3包含n个值为i的元素。 ④vector<T> v4(n); v4含 阅读全文
posted @ 2016-04-08 12:06 us4ever 阅读(245) 评论(0) 推荐(0)
 
 

2016年4月6日

C++:关于set
摘要: 1. set的初始化 set可以这样初始化: 在初始化set的时候,若出现重复的元素: 则多余的重复元素在储存时被删去,若打印出来,set中只有1,2,3三个元素。 2. 关于set的迭代器 由于set并没有定义+和-操作,所以没有办法用set.iterator+n的方式指定迭代器,比如这样 set 阅读全文
posted @ 2016-04-06 17:54 us4ever 阅读(3109) 评论(0) 推荐(0)
 
 

2016年4月5日

Number of Digit X,X=0-9
摘要: 从问题Number of Digit One延伸来,计算从1到给定的数字n共n个数字中,数字X出现的次数。 直观上来看,如果X是1-8之间的数字,那规律和之前在Number of Digit One 中分析的是一样的,因为对每个digit上的数字进行分析的话,都需要考虑三种情况,即给定的n上该位数字 阅读全文
posted @ 2016-04-05 21:09 us4ever 阅读(249) 评论(0) 推荐(0)
 
Number of Digit One 数字1的个数 (LeetCode 233)
摘要: 题目:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. (LeetCode 233) Hint: 提示放在最后面了 阅读全文
posted @ 2016-04-05 16:48 us4ever 阅读(398) 评论(0) 推荐(0)
 
 

2016年4月4日

N-Queens N皇后问题 (LeetCode 51)
摘要: 题目:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. (LeetCode 51) Given an integ 阅读全文
posted @ 2016-04-04 18:00 us4ever 阅读(268) 评论(0) 推荐(0)
 
Factorial Trailing Zeroes 阶乘尾零 (Leetcode 172)
摘要: 题目:Given an integer n, return the number of trailing zeroes in n!.(Leetcode 172) Note: Your solution should be in logarithmic time complexity. C++参考框架 阅读全文
posted @ 2016-04-04 17:43 us4ever 阅读(150) 评论(0) 推荐(0)
 
 

2016年4月3日

C++随记
摘要: 记录一些零散的C++笔记,同一topic的内容多了之后再整理到一起。 1. vector的初始化。 vector可以这样初始化: vector也可以这样初始化: 用已存在的数组元素来初始化vector。传给vector的an_array和an_array+4(指针作为数组的迭代器)指示把范围 [an 阅读全文
posted @ 2016-04-03 23:17 us4ever 阅读(145) 评论(0) 推荐(0)
 
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3