- 博客(30)
- 收藏
- 关注
原创 LeetCode199—Binary Tree Right Side View
原题原题链接 Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For example: Given the following binary t
2017-01-25 19:32:46 377
原创 LeetCode198—House Robber
原题原题链接 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacen
2017-01-25 18:31:32 333
原创 LeetCode191—Number of 1 Bits
原题原题链接 Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 00000
2017-01-25 18:28:22 343
原创 redis源码学习之整数集合
整数集合intset的底层实现比较简单,因为它所有的key都是整型,只是整型分为16bits、32bits和64bits这三种类型,当新插入的元素比当前集合中所有数还要长时,就要进行升级了,这部分源码很简单,主要就是升级部分。数据结构/* * intset 的编码方式 */#define INTSET_ENC_INT16 (sizeof(int16_t))#define INTSET_EN
2017-01-25 16:47:23 471
原创 LeetCode190—Reverse Bits
原题https://leetcode.com/problems/reverse-bits/Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 96417
2017-01-18 17:22:48 474
原创 LeetCode189—Rotate Array
原题https://leetcode.com/problems/rotate-array/Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].分析比较难的是如果只能
2017-01-18 16:29:14 362
原创 redis源码学习之字典
数据结构几个重要的数据结构: dict、dictht、dictEntry分别表示字典,hash表,hash桶。 字典结构体,主要包含了hash表数组(有两个hash表,其中一个备用做rehash用)。typedef struct dict { // 类型特定函数 dictType *type;//函数指针 // 私有数据 void *privdata; /
2017-01-17 21:00:06 480
原创 LeetCode208—Implement Trie (Prefix Tree)
原题看了WIKI才知道怎么回事。原题链接 Implement a trie with insert, search, and startsWith methods. Note: You may assume that all inputs are consist of lowercase letters a-z.分析实现一个前缀树/字典树 要求实现插入、查找、前缀查找clas
2017-01-11 21:26:13 409
原创 LeetCode207—Course Schedule
原题原题链接 There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expre
2017-01-11 11:23:31 309
原创 LeetCode206—Reverse Linked List
原题原题链接 Reverse a singly linked list.分析逆序一个单链表。 链表操作的题目了,这里需要三个指针,需要额外的一个指针保存当前指针的next节点,因为逆转之后,该节点就跟原链表断开了。代码class Solution { public: ListNode* reverseList(ListNode* head) { if(NULL
2017-01-04 21:44:34 413
原创 LeetCode205—Isomorphic Strings
原题原题链接 Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replac
2017-01-04 21:41:03 333
原创 LeetCode204—Count Primes
原题原题链接 Description: Count the number of prime numbers less than a non-negative number, n.分析找到小于n的所有素数的个数。 没什么说的,如果迭代判断一个数是否是素数肯定是超时的复杂度o(n2)o(n^2) 用埃拉托斯特尼筛选法来解。即先假定2~n所有的数都是素数,那么遍历之后,如果i是素数,那
2017-01-04 21:35:31 457
原创 undefined reference to `vtable for boost::detail::thread_data_base'问题
同样是boost.asio中用到boost.thread处理I/O,编译出错: undefined reference to `vtable for boost::detail::thread_data_base’环境ubuntu14.04 g++ 4.8.4解决办法I had the same question, but -lboost_thread-mt is now deprecated
2017-01-03 16:24:08 5445
原创 undefined reference to `boost::system::generic_category()问题
最近学习boost.asio,写了个简单的server.cpp编译出错: undefined reference to `boost::system::generic_category()环境:ubuntu14.04 g++4.8.4解决办法You should link in the libboost_system library. I am not sure about codeblocks,
2017-01-03 16:21:42 11030
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人