- 博客(16)
- 资源 (10)
- 收藏
- 关注
原创 Remove Nth Node From End of List —— Leetcode
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the
2015-03-31 10:51:08 498
原创 Longest Common Prefix —— Leetcode
Write a function to find the longest common prefix string amongst an array of strings.本想用C++写,但想想太没挑战性,干脆直接用C。下面是代码,然而,和很多leetcoder提交的答案一样,在[""]这个测试用例下卡住了,不知为何。方法很简单,就是所有字符串从第一个开始向后遍历,直到有不一样的,即为公共
2015-03-31 10:29:55 563
原创 String to Integer (atoi) —— Leetcode
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca
2015-03-30 15:41:04 423
原创 Min Stack —— Leetcode
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get
2015-03-27 14:54:55 464
原创 反转一个整数
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to ask before coding. Bonus points for y
2015-03-26 22:14:07 1027
原创 版本号的比较
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co
2015-03-24 20:47:36 463
原创 统计一个数的阶乘后面0的个数
Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.要求对数时间。首先分析,只有2*5=10才会产生一个0,N!中2的数量永远大于5的数量,所以该题的目标简化为求N!中5的个数。
2015-03-23 15:21:39 924
原创 输出Pascal's Triangle(杨辉三角)
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]C++做此题,很简单,但由于STL的vector掌握不好
2015-03-22 22:09:12 925
原创 反转二进制数
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as0011100101
2015-03-20 10:59:53 3192
原创 二进制中1的个数
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 000000
2015-03-20 10:24:05 481
原创 单机存储系统
首先,我们下个定义,什么是单机存储引擎?单机存储引擎就是哈希表、B树等数据结构在机械磁盘、SSD等持久化介质上的实现。单机存储系统的理论来源于关系数据库,关系数据库中,事务(一组操作)的ACID特征要牢记(Atomicity, Consistency, Isolation, Durability)。1. 硬件基础这些是最底层的硬件基础。(1)CPU架构经典的多CPU
2015-03-18 20:53:51 2236
原创 分布式存储系统概述
云计算、大数据,这些热点词汇,后台的基础设施离开不了分布式存储系统,它的两个特点,一是规模大,二是成本低。其实分布式系统的设计是根据需求来变化的,那么我们接下来就看,我们需要存储哪些数据,以及,分布式存储系统有哪些分类。1. 分布式存储的数据大致可以分为三类:非结构化数据:文档、图片、视频等;结构化数据:这个最容易理解,关系数据库中存的表(比如员工名称、信息等等),模式
2015-03-18 20:31:30 1292
原创 C++成员函数
“The Semantics of Function”,本篇的架构很简单,说的是member functions在nonstatic,static和virtual三种状态下的调用方式。首先来一个开胃菜:假设类Point3d有data members x, y, z,有member function如下,floatPoint3d::magnitude() const{ retur
2015-03-10 20:13:25 549
原创 C++数据成员
第三章的标题是“The semantics of data”,讲的是data members在继承、多态下的特性。(1)如果一个class中不含data,那么它在sizeof的运算下的表现是什么样的?假如我们有如下继承关系,并且这四个类中都不包含任何数据成员:class X { };class Y : public virtual X { };class Z : publi
2015-03-09 10:32:51 755
原创 Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element
2015-03-06 18:17:38 452
原创 链表反转
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy t
2015-03-04 21:57:32 486
Cisco IP Routing: Packet Forwarding and Intra-domain Routing Protocols
2012-05-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人