c++
文章平均质量分 62
-缘故-
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 4.1.3 Largest Rectangle in Histogram
4.1.3 Largest Rectangle in Histogram 描述 Given n non-negative integers representing the histogram’s bar height where the width of each bar is1, find the area of largest rectangle in the histogram.原创 2016-04-18 17:18:15 · 403 阅读 · 0 评论 -
num的n次方 O(log(n))
int power(int a, int e){ int res=1; while(e){ if(e&1){ res = res*a; } e>>=1; a = a*a; } return res; }原创 2017-09-05 12:39:24 · 515 阅读 · 0 评论 -
c++ STL 笔记
char 转 string stringstream ss; ss<<ch; string tmp; ss>>tmp;string str(1,'c'); string大小写转化 transform(strA.begin(), strA.end(), strA.begin(), ::toupper); transform(strA.begin(), strA.end(), strA.begi原创 2017-09-06 10:17:58 · 279 阅读 · 0 评论 -
c++ 内存强制释放
malloc_trim(0);原创 2019-01-02 10:22:05 · 2910 阅读 · 0 评论 -
c++ regex 替换
#include &lt;iostream&gt; #include &lt;regex&gt; #include &lt;string&gt; void set_args(string &amp; text, const string&amp; key, const string&amp; value, bool add_args=true) {原创 2019-01-02 10:22:34 · 510 阅读 · 0 评论 -
c++ git上的log库使用
//https://github.com/q191201771/starry-night/tree/master/src/base /* chef_log.cc chef_log.h */ bool debuglog; chef::log::init(debuglog ? chef::log::mode::mode_debug : chef::log::mode::mode_re...原创 2019-01-02 10:22:43 · 303 阅读 · 0 评论 -
c++ git上的task thread库 使用
//https://github.com/q191201771/starry-night/tree/master/src/base /* chef_env.hpp chef_noncopyable.hpp chef_task_thread.cc chef_task_thread.h chef_wait_event_counter.cc chef_wait_event_counter.h */ t...原创 2019-01-02 10:23:01 · 497 阅读 · 0 评论 -
c++ 文件操作的 单例模式 范例
//.h #include &lt;stdint.h&gt; #include &lt;fstream&gt; #include &lt;mutex&gt; class File { public: static File &amp;instance(); void write(const std::string &amp;str); p原创 2019-01-03 15:12:55 · 525 阅读 · 0 评论 -
c++ rapidjson库的使用
//rapijson #include &lt;rapidjson/document.h&gt; #include &lt;rapidjson/istreamwrapper.h&gt; #include "rapidjson/error/en.h" #include &lt;fstream&gt; #define has_uint(val, key) (原创 2019-01-03 15:12:47 · 1235 阅读 · 0 评论 -
Uber面试题2 | House Robber III
题目描述 小偷找到了一个新的偷盗地点,这里地区的房子组成了一棵二叉树,地区的入口是二叉树的根所在的房子。如果小偷同时偷窃了两个直接相邻的房子,就会触发警报器。求在不触发警报器的情况下小偷可以抢到的最多的money。 Example: 3 / \ 2 3 \ \ 3 1 小偷可以抢到的最多的money是3+3+1=转载 2016-05-04 16:48:22 · 861 阅读 · 0 评论 -
Uber面试题1 | 房屋窃贼 House Robber II
题目描述 小偷找到了一个新的偷盗地点,这个地区的房子组成了一个环,如果小偷同时偷窃了两个直接相邻的房子,就会触发警报器。在不触发警报器的情况下,求小偷可以抢到的最多的money。 解题思路 本题是House Robber的follow up。 House Robber-i中房子排列成一个序列,用动态规划就可以 动态规划四要素说说dp状态的定义:df[i]表示前i个转载 2016-05-04 16:42:59 · 797 阅读 · 0 评论 -
LeetCode 3.5 Longest Palindromic Substring
3.5 Longest Palindromic Substring 描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximumlength of S is 1000, and there exists one unique longest palindr原创 2016-04-18 15:38:26 · 356 阅读 · 0 评论 -
LeetCode 2.1.24 Single Number II
2.1.24 Single Number II 描述 Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could yo原创 2016-04-18 13:37:57 · 388 阅读 · 0 评论 -
LeetCode 2.1.21 Gas Station
2.1.21 Gas Station 描述 There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] o原创 2016-04-18 12:17:06 · 358 阅读 · 0 评论 -
LeetCode 2.1.10 4Sum
2.1.10 4Sum 描述 Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target?Find all unique quadruplets in the array which gives the sum of targe原创 2016-04-18 11:20:09 · 302 阅读 · 0 评论 -
LeetCode 2.1.16 Rotate Image
2.1.16 Rotate Image 描述 You are given an n × n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? 分析 首先想到,纯模拟,从外到内一圈一圈的转,但这个方法太慢原创 2016-04-18 11:13:59 · 336 阅读 · 0 评论 -
C++ 字典遍历
CCDictElement * pElement; CCDICT_FOREACH(result, pElement) { const char * key = pElement->getStrKey(); CCString * value = (CCString *)pElement->getObject(); CCLog(key);原创 2016-05-10 17:31:06 · 4967 阅读 · 0 评论 -
二叉树遍历 Morris O(1)空间复杂度
本文主要解决一个问题,如何实现二叉树的前中后序遍历,有两个要求: 1. O(1)空间复杂度,即只能使用常数空间; 2. 二叉树的形状不能被破坏(中间过程允许改变其形状)。 通常,实现二叉树的前序(preorder)、中序(inorder)、后序(postorder)遍历有两个常用的方法:一是递归(recursive),二是使用栈实现的迭代版本(stack+iterativ转载 2016-04-18 18:38:45 · 5562 阅读 · 0 评论 -
LeetCode 13.7 Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = “great”: great / \ gr原创 2016-05-03 16:01:14 · 397 阅读 · 0 评论 -
C++ BOOST笔记 时间, 指针
时间 //当前时钟 std::chrono::duration_cast&lt;std::chrono::milliseconds&gt;( std::chrono::steady_clock::now().time_since_epoch()).count() //当前时间戳 std::chr...原创 2019-01-03 15:12:38 · 544 阅读 · 0 评论
分享