![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
carbon06
这个作者很懒,什么都没留下…
展开
-
Tensorflow 编译及应用C++动态库
背景Tensorflow 是google开源的目前最流行的深度学习框架。 TensorFlow 源码基于c++ 开发,提供了java, c, c++, python等主流编程语言支持。目前业界主流的应用方式是使用Tensorflow python构建以及训练模型,模型训练完成后使用c++ 或者java将模型应用到生产环境。 本文主要介绍如何将Tensorflow编译成动态库以便于其他工程使...原创 2018-09-10 12:56:31 · 2900 阅读 · 3 评论 -
[LeetCode] Print Binary Tree
题目描述Print a binary tree in an m*n 2D string array following these rules:The row number m should be equal to the height of the given binary tree. The column number n should always be an odd number...原创 2018-07-04 12:31:33 · 147 阅读 · 0 评论 -
[LeetCode] 725. Split Linked List in Parts
题目描述Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list “parts”.The length of each part should be as equal as possible: no tw...原创 2018-07-16 11:45:19 · 177 阅读 · 0 评论 -
[LeetCode] 866. Smallest Subtree with all the Deepest Nodes
题目描述Given a binary tree rooted at root, the depth of each node is the shortest distance to the root.A node is deepest if it has the largest depth possible among any node in the entire tree.The s...原创 2018-07-09 19:16:57 · 558 阅读 · 0 评论 -
[LeetCode] 860. Lemonade Change
题目描述At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills).Each customer will only buy one lemo...原创 2018-07-02 13:03:03 · 579 阅读 · 0 评论 -
c++ cout 不能正常打印uint8_t
问题现象编译运行以下代码/************************************************************************* > File Name: cout_uint8.cpp > Author: liuce03 > Mail: liuce03@meituan.com > Creat...原创 2018-06-29 14:36:38 · 9516 阅读 · 0 评论 -
[LeetCode] 817. Linked List Components
题目描述We are given head, the head node of a linked list containing unique integer values.We are also given the list G, a subset of the values in the linked list.Return the number of connected comp...原创 2018-05-31 14:44:58 · 328 阅读 · 0 评论 -
[LeetCode] 807. Max Increase to Keep City Skyline
题目描述In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amoun...原创 2018-05-30 17:35:24 · 363 阅读 · 0 评论 -
[LeetCode] 841. Keys and Rooms
题目描述There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, …, N-1, and each room may have some keys to access the next room. Formally, each room i has a list of ke...原创 2018-05-30 12:54:28 · 934 阅读 · 0 评论 -
[LeetCode] 844. Backspace String Compare
题目描述Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.Example 1:Input: S = "ab#c", T = "ad#c"Output: trueExplanat...原创 2018-06-05 19:49:25 · 965 阅读 · 0 评论 -
C++利用宏实现统计运行时间工具
背景OSRM backend 代码中有一个timing_util.hpp的头文件,利用宏以及c++11 chrono 实现了统计代码运行时间的工具。 在工程中统计代码运行时间非常常用,本文介绍OSRM timing_util的实现原理,并用示例来说明。实现解析#ifndef TIMING_UTIL_HPP#define TIMING_UTIL_HPP#include &lt...原创 2018-06-05 18:04:19 · 1966 阅读 · 0 评论 -
[LeetCode] 565. Array Nesting
题目描述A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], … } subjected to the rule below.Su...原创 2018-05-29 20:07:35 · 141 阅读 · 0 评论 -
[LeetCode] 539. Minimum Time Difference
题目描述Given a list of 24-hour clock time points in “Hour:Minutes” format, find the minimum minutes difference between any two time points in the list. Example 1:Input: ["23:59","00:00"]Output: 1...原创 2018-06-12 18:08:36 · 194 阅读 · 0 评论 -
Linux cmake 静态链接boost库
背景使用动态链接编译的二进制程序在执行时要求开发环境与生产环境严格一致,因此我们更倾向于使用静态链接的方式链接第三方库。本文介绍如何在Linux 环境下使用cmake 静态链接Boost 库。示例我们将编译好boost静态库.a 文件和头文件放入third_party 目录,在CMakeLists.txt 中使用find_package 方法查找boost静态库。 我自己在Cen...原创 2018-06-05 16:59:54 · 7023 阅读 · 0 评论 -
[LeetCode] 869. Reordered Power of 2
题目描述Starting with a positive integer N, we reorder the digits in any order (including the original order) such that the leading digit is not zero.Return true if and only if we can do this in a way...原创 2018-07-17 19:22:15 · 346 阅读 · 0 评论 -
[LeetCode] 378. Kth Smallest Element in a Sorted Matrix
题目描述Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order,...原创 2018-07-12 10:55:13 · 192 阅读 · 0 评论 -
Tensorflow 编译及应用C++静态库
背景目前对Tensorflow的主流应用模式是使用python训练模型,使用c++或者java应用训练好的模型。上篇博客介绍了如何在工程中应用Tensorflow 动态库,本博客介绍如何在工程中应用Tensorflow静态库编译静态链接库clone tensorflow git 仓库git clone https://github.com/tensorflow/tensor...原创 2018-09-11 21:07:48 · 4481 阅读 · 5 评论 -
g++ warn_unused_result
介绍在编程过程中,有的函数我们需要确保函数的返回值必须被使用。但是如果函数使用者直接调用函数且不使用函数的返回值的话,g++ 不会给出warning。这样可能会导致很难寻觅的bug。如调用realloc函数,函数调用者必须使用函数的返回值获得重新分配内存的指针。 利用g++ common function attributes 中提供的warn_unused_result 可以保证函数的返回...原创 2018-08-24 14:22:07 · 4612 阅读 · 1 评论 -
C++11 智能指针
智能指针的思想c++ 要求程序员自己管理内存,为程序员提供了更高自由度,但更高的自由度同时意味着更多责任。为了减少c++程序员在使用裸指针时可能带来的内存泄露,c++11 引入智能指针帮助程序员管理内存。智能指针背后的设计思想是RAIIunique_ptrunique_ptr 设计的目的是保证指针变量只指向一个实体,避免出现有其他指针变量指向相同实体,或者此指针变量指向同类型的其他...原创 2018-08-08 16:47:51 · 184 阅读 · 0 评论 -
Json library implemented by boost variant
Json library implemented by boost variantboost variant 介绍boost variant 是一个不同union的泛型类,用于存储和操作不同类型但在使用时存在相同抽象的对象。variant 在实现不同类型的泛型的同时,提供对其包括的具体类型的安全访问。 基于此性质,boost variant 可以应用于json 这种数据结构,我们把j...原创 2018-08-01 19:18:51 · 256 阅读 · 0 评论 -
Trie C++ 实现与解析
Trie tree 介绍trie 源自 retrieval ,中文称为前缀树或字典树。具体介绍见wiki trieC++ 实现以下trie实现支持任何语言(Chinese,English,Janpanse…)。主要包括以下三个接口// 使用一组词初始化trie.void Init(const std::vector<std::string>& dict...原创 2018-07-20 16:42:57 · 1084 阅读 · 0 评论 -
[LeetCode] 648. Replace Words
题目描述In English, we have a concept called root, which can be followed by some other words to form another longer word - let’s call this word successor. For example, the root an, followed by other, wh...原创 2018-07-19 19:31:57 · 193 阅读 · 0 评论 -
[LeetCode] 756. Pyramid Transition Matrix
题目描述We are stacking blocks to form a pyramid. Each block has a color which is a one letter string, like 'Z'.For every block of color C we place not in the bottom row, we are placing it on top of a...原创 2018-07-13 18:12:19 · 447 阅读 · 0 评论 -
[LeetCode] 676. Implement Magic Dictionary
题目描述Implement a magic directory with buildDict, and search methods.For the method buildDict, you’ll be given a list of non-repetitive words to build a dictionary.For the method search, you’ll be...原创 2018-07-06 12:49:06 · 198 阅读 · 0 评论 -
[LeetCode] 470. Implement Rand10() Using Rand7()
题目描述Given a function rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10 which generates a uniform random integer in the range 1 to 10.Do NOT use system’s M...原创 2018-07-18 17:44:55 · 1008 阅读 · 0 评论 -
[LeetCode] 874. Design Circular Deque
题目描述Design your implementation of the circular double-ended queue (deque). Your implementation should support following operations:MyCircularDeque(k): Constructor, set the size of the deque to be...原创 2018-07-12 15:41:43 · 471 阅读 · 0 评论 -
[LeetCode] 709. To Lower Case
题目描述Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. 题目的要求非常简单,即将一个字符串中的大写字母全部转化为小写。 解决思路是利用ascii码进行转化,A-Z 的ascii 码是65-90 ,a-z 的ascii 码是9...原创 2018-07-12 15:06:34 · 1105 阅读 · 0 评论 -
[LeetCode] 337. House Robber III
题目描述The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After ...原创 2018-07-05 19:39:25 · 131 阅读 · 0 评论 -
c++ 将git提交信息编译到可执行文件
在生产环境中经常需要查看在线上运行的程序对应git的哪次提交。 我们可以在编译时获取git 最后一次提交信息GIT_SHA1 宏,C++ 程序通过访问GIT_SHA1宏可以输出和git仓库的提交信息。 使用Makefile时,在Makefile 添加以下CPPFLAGS+=-DGIT_SHA1="$(shell git log --format='[sha1]:%h [author]:...原创 2018-07-12 11:45:04 · 1512 阅读 · 0 评论 -
[LeetCode] 721. Accounts Merge
题目描述Given a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account...原创 2018-05-29 15:55:43 · 468 阅读 · 0 评论 -
[LeetCode] 542. 01 Matrix
题目描述Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1. Example 1: Input:0 0 00 1 00 0 0Output:0 0 00...原创 2018-05-24 12:33:44 · 357 阅读 · 0 评论 -
LRU Cache 解析及实现
LRU Cache 原理LRU是Least Recently Used 的缩写,是一种缓存替换算法,当系统中的缓存满时,通过删除最近最少使用的元素来填充新的内容。LRU 算法在操作系统中有广泛应用,如CPU与物理内存之间的Cache替换算法, 物理内存与硬盘之间Cache替换算法。LRU Cache 实现我们可以使用一个双向链表和hash map 实现LRU Cache,其中hash ...原创 2018-04-02 18:00:15 · 486 阅读 · 0 评论 -
[LeetCode] 811. Subdomain Visit Count
811. Subdomain Visit Count题目描述A website domain like “discuss.leetcode.com” consists of various subdomains. At the top level, we have “com”, at the next level, we have “leetcode.com”, and at the lo...原创 2018-04-02 16:33:32 · 286 阅读 · 0 评论 -
[LeetCode] 804. Unique Morse Code Words
804. Unique Morse Code Words题目描述International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: “a” maps to “.-“, “b” maps to “-…”, “c”...原创 2018-04-02 14:49:00 · 830 阅读 · 0 评论 -
[LeetCode] 748. Shortest Completing Word
748. Shortest Completing WordFind the minimum length word from a given dictionary words, which has all the letters from the string licensePlate. Such a word is said to complete the given string lice...原创 2018-03-23 15:11:35 · 294 阅读 · 0 评论 -
c++ 将一个char 转化为string
const char c = 'a';//1.使用 string 的构造函数string s(1,c);//2.声明string 后将char push_backstring s1;s1.push_back(c);//3.使用stringstreamstringstream ss;ss << c;string str2 = ss.str();//注意 使用to_s...原创 2018-02-23 15:12:00 · 76246 阅读 · 4 评论 -
[LeetCode] 495. Teemo Attacking
问题描述In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo’s attacking ascending time series towards Ashe and the poisoni...原创 2018-03-15 19:58:20 · 130 阅读 · 0 评论 -
[LeetCode] 791. Custom Sort String
S and T are strings composed of lowercase letters. In S, no letter occurs more than once.S was sorted in some custom order previously. We want to permute the characters of T so that they match the o...原创 2018-02-28 20:00:00 · 498 阅读 · 0 评论 -
c++ 中RAII的含义
RAII 是 Resource Acquisition Is Initialization(资源获取即初始化)的缩写。RAII 是C++ 中常用的一种编程技术,具体是指必须在使用前获取的资源(如栈内存,线程,文件,锁,数据库连接,磁盘空间)的声明周期绑定在一个对象的生命周期,这样使用者就不需要自己去释放资源,避免资源泄露。 RAII 保证资源可用于任何会访问该对象的函数。它亦保证所有资源的在其控...转载 2018-03-07 20:12:15 · 1603 阅读 · 0 评论 -
OpenMp Tutorial
What is openmpeasy multithreading programing for c++.it is a simple C/C++/Fortran complier extension that allows to add parallelism into existing source code without significantly having to rewrit...原创 2018-02-27 19:06:18 · 380 阅读 · 0 评论