自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

R_xiaozhu_Q的专栏

love what i'm loving~

  • 博客(292)
  • 资源 (4)
  • 收藏
  • 关注

原创 【LeetCode】Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.思路:第一遍正常复制链表,同时用哈希表保存链表中原始节点和新

2014-08-07 19:39:41 976

原创 【LeetCode】Reverse Linked List II

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

2014-08-07 17:16:02 1056

原创 【LeetCode】Pow(x, n)

Implement pow(x, n).思路:快速幂运算,需要考虑指数为负数,同时底数为0的情况,这种属于异常数据,代码里没有体现。class Solution {public: double pow_abs(double x, unsigned int n) { if (n == 0) { return 1;

2014-08-04 20:49:46 889

原创 【LeetCode】Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree./** * Definition for binary tree * struct TreeNode {

2014-08-01 16:47:06 957

原创 【LeetCode】Partition List

Given a linked list and a value x, partition it such that all nodes less thanx come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of

2014-08-01 11:26:35 839

原创 C++ string 实现大整数相加减

任意两个大整数的加减算法,可自动判断正负号,代码如下:#include #include #include #include #include using namespace std;string BigInegerAdd(string s1, string s2) // s1+s2;{ int len = s1.size()>s2.size()?s1.size()+1:s

2014-07-31 15:45:56 4268 1

原创 【LeetCode】Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

2014-05-19 20:20:17 848

转载 【LeetCode】Reorder List

zhuhttp://www.programcreek.com/2013/12/in-place-reorder-a-singly-linked-list-in-java/

2014-05-19 15:55:26 660

原创 【LeetCode】LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:get and set.get(key) - Get the value (will always be positive) of the key if t

2014-05-19 08:54:49 917

原创 【华为编程大赛】洞穴逃生

洞穴逃生 描述: 精灵王子爱好冒险,在一次探险历程中,他进入了一个神秘的山洞。在洞穴深处,精灵王子不小心触动了洞穴内暗藏的机关,整个洞穴将很快塌陷,精灵王子必须尽快逃离洞穴。精灵王子的跑步速度为17m/s,以这样的速度可能是无法逃出洞穴的。庆幸的是精灵王子拥有闪烁法术,可在1s内移动60m,不过每次使用闪烁法术都会消耗魔法值10点。精灵王子的魔法值恢复的速度为4点/s,只有处在原地休息状态

2014-05-08 14:05:06 2930

原创 【华为编程大赛】实现一个开放的书名检索库

描述:实现一个开放的书名检索库,库中存储了若干个书名用户可以:1. 通过接口加入书名2. 指定搜索条件搜索库中符合条件的书名重要格式说明单词:由小写英文字母组成,不含其它字符书名:1. 由一个或多个单词组成2. 当包含多个单词时,单词间用一个空格分隔3. 第一个单词前和最后一个单词后没有空格4. 若只包含一个单词,则该单词前后均无空格搜索条件:

2014-05-06 21:10:27 3099 1

原创 【华为编程大赛】投票问题

输入若干候选人,以及投票,格式如下,输出(按输入候选人输入顺序)候选人以及得票,以及无效票数。Input:addCandidate xx1addCandidate xx2addCandidate xx3addCandidate xx4addCandidate xx5addCandidate xx6vote xx2vote xx2vote xx3vot

2014-05-06 21:08:00 1414 1

原创 【Union Find】JAVA implementation

import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.Scanner;class UF{ private int[] id; private int count; public UF(int N) { count = N; id = n

2014-05-03 16:32:16 1493

原创 【LeetCode】Substring with Concatenation of All Words

You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an

2014-05-03 15:18:57 803

转载 【字符串动态规划】最长回文字串+交替字符串

Interleaving StringTotal Accepted: 7740 Total Submissions: 41615 Given s1, s2, s3, find whether s3 is formed by the interleaving ofs1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca"

2014-05-03 10:40:29 1481

原创 【微软编程一小时】题目1 : Arithmetic Expression

时间限制:2000ms单点时限:200ms内存限制:256MB描述Given N arithmetic expressions, can you tell whose result is closest to 9?输入Line 1: N (1 Line 2..N+1: Each line contains an expression in the f

2014-04-28 18:54:25 1124

原创 【微软2014实习生及秋令营技术类职位在线测试】题目3 : Reduce inversion count

时间限制:10000ms单点时限:1000ms内存限制:256MBDescriptionFind a pair in an integer array that swapping them would maximally decrease the inversion count of the array. If such a pair exists, retur

2014-04-27 11:57:37 1396 1

原创 【InversionCount 逆序对数 + MergeSort】

Definition of Inversion: Let (A[0], A[1] ... A[n], n A[j], then the pair (i, j) is called inversion of A.Example:Count(Inversion({3, 1, 2})) = Count({3, 1}, {3, 2}) = 2思路,如果用brute force,则O(n^2)

2014-04-26 22:02:10 1729

原创 【微软2014实习生及秋令营技术类职位在线测试】题目2 : K-th string

时间限制:10000ms单点时限:1000ms内存限制:256MBDescriptionConsider a string set that each of them consists of {0, 1} only. All strings in the set have the same number of 0s and 1s. Write a program

2014-04-26 10:39:18 1295

原创 【微软2014实习生及秋令营技术类职位在线测试】题目1 : String reorder

时间限制:10000ms单点时限:1000ms内存限制:256MBDescriptionFor this question, your program is required to process an input string containing only ASCII characters between ‘0’ and ‘9’, or between ‘a

2014-04-25 21:14:48 1144

原创 【编程之美挑战赛第一场】活动中心

时间限制:12000ms单点时限:6000ms内存限制:256MB描述A市是一个高度规划的城市,但是科技高端发达的地方,居民们也不能忘记运动和锻炼,因此城市规划局在设计A市的时候也要考虑为居民们建造一个活动中心,方便居住在A市的居民们能随时开展运动,锻炼强健的身心。城市规划局希望活动中心的位置满足以下条件:1. 到所有居住地的总距离最小。2. 为了方

2014-04-24 22:31:03 1617

原创 【编程之美挑战赛第一场】树

时间限制:4000ms单点时限:2000ms内存限制:256MB描述有一个N个节点的树,其中点1是根。初始点权值都是0。一个节点的深度定义为其父节点的深度+1,。特别的,根节点的深度定义为1。现在需要支持一系列以下操作:给节点u的子树中,深度在l和r之间的节点的权值(这里的深度依然从整个树的根节点开始计算),都加上一个数delta。问完成所有操作后,

2014-04-19 16:29:37 985

原创 【编程之美挑战赛第一场】焦距

时间限制:2000ms单点时限:1000ms内存限制:256MB描述一般来说,我们采用针孔相机模型,也就是认为它用到的是小孔成像原理。在相机坐标系下,一般来说,我们用到的单位长度,不是“米”这样的国际单位,而是相邻像素的长度。而焦距在相机坐标系中的大小,是在图像处理领域的一个非常重要的物理量。假设我们已经根据相机参数,得到镜头的物理焦距大小(focal

2014-04-19 16:26:04 1173

原创 【HackerRank】Common Child (LCS)最长公共子序列

Given two strings a and b of equal length, what’s the longest string (S) that can be constructed such thatS is a child to both a and b.String x is said to be a child of string y if x can be formed

2014-04-19 16:22:45 3060

原创 【HackerRank】Red John is Back (Dynamic programming)简单递推

Red John has committed another murder. But this time, he doesn’t leave a red smiley behind. What he leaves behind is a puzzle forPatrick Jane to solve. He also texts Teresa Lisbon that if Patrick is

2014-04-13 17:28:45 1489

转载 【HackerRank】Angry Children 2 排序+动态规划

Bill Gates is on one of his philanthropic journeys to a village in Utopia. He hasN packets of candies and would like to distribute one packet to each of theK children in the village (each packet m

2014-04-07 15:57:04 2098

原创 【剑指offer】题目1371:最小的K个数

题目描述:输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。输入:每个测试案例包括2行:第一行为2个整数n,k(1第二行包含n个整数,表示这n个数,数组中的数的范围是[0,1000 000 000]。输出:对应每个测试案例,输出最小的k个数,并按从小到大顺序打印。样例输入:8 4

2014-04-04 15:42:51 931

原创 【剑指offer】题目1385:重建二叉树

题目描述:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并输出它的后序遍历序列。输入:输入可能包含多个测试样例,对于每个测试案例,输入的第一行为一个整数n(1输入的第二行包括n个整数(其

2014-04-04 13:04:47 837

原创 【剑指offer】题目1510:替换空格

题目描述: 请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。输入: 每个输入文件仅包含一组测试样例。对于每组测试案例,输入一行代表要处理的字符串。输出: 对应每个测试案例,出经过处理后的字符串。样例输入: We Are Happy样例输出:

2014-04-03 21:43:56 886

原创 【剑指offer】二维数组中的查找

题目描述: 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。输入: 输入可能包含多个测试样例,对于每个测试案例,输入的第一行为两个整数m和n(1输入的第二行包括一个整数t(1接下来的m行,每行有n个数,代表题目所给出的m行n列的矩阵(矩阵如题目描述所示,

2014-04-03 21:21:35 977

原创 【LeetCode】Sort List

Sort a linked list in O(n log n) time using constant space complexity./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : v

2014-03-16 11:22:59 830

原创 【LeetCode】Evaluate Reverse Polish Notation

Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+",

2014-03-16 10:16:31 773

原创 【LeetCode】Reverse Words in a String

Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes a wor

2014-03-15 21:01:47 1890

原创 【LeetCode】N-Queens II N皇后问题 回溯法

N-Queens IITotal Accepted: 4852 Total Submissions: 16065 Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.

2014-03-15 20:46:05 1779

原创 【程序员的自我修养】从分段机制到分页机制

操作系统的多任务性使得CPU在多个进程之间共享,从进程的角度来看,就是一个进程独占一个CPU,IO抽象模型也很好地实现了IO设备的共享,那么内存的分配与共享就交给虚拟存储器来管理了。    早期计算机中,程序是直接运行在物理内存上的,就是程序运行时访问的都是PA(物理地址),我们必须同时在内存中运行多个程序,那么有限的RAM空间如何分配呢?直接分配的策略有如下问题:    1:地址空间不隔

2014-03-09 22:18:38 1102

原创 Linux 内存寻址

80x86微处理器下的三种不同的地址:逻辑地址:16位段选择符+32位offset, 段选择符存放在段寄存器中线性地址:也称为虚拟地址,32bit 体系结构可以表达4GB的地址空间物理地址:芯片内存单元寻址MMU 通过分段单元将 逻辑地址转换为线性地址;分页单元将线性地址转换为物理地址;分段的过程:段选择符有三个字段:1)Index字段,表示

2014-03-06 14:00:57 875

原创 存储器层次结构及高速缓存cache的思考

首先给出一个存储器的金字塔形结构图:                                                  L0 寄存器 Regs.   (CPU在一个时钟周期内可以访问到)                                               L1 高速缓存  SRAM   几个时钟cycles                    

2014-03-03 21:48:04 1941

转载 深刻理解Linux进程间通信(IPC)

materials from : http://www.ibm.com/developerworks/cn/linux/l-ipc/    一个大型的应用系统,往往需要众多进程协作,进程(Linux进程概念见附1)间通信的重要性显而易见。本系列文章阐述了Linux环境下的几种主要进程间通信手段,并针对每个通信手段关键技术环节给出详细实例。为达到阐明问题的目的,本文还对某些通信手段的

2014-02-09 16:11:48 647

转载 Linux用户空间与内核空间

Linux 操作系统和驱动程序运行在内核空间,应用程序运行在用户空间,两者不能简单地使用指针传递数据,因为Linux使用的虚拟内存机制,用户空间的数据可能被换出,当内核空间使用用户空间指针时,对应的数据可能不在内存中。Linux内核地址映射模型x86 CPU采用了段页式地址映射模型。进程代码中的地址为逻辑地址,经过段页式地址映射后,才真正访问物理内存。段

2013-12-27 12:03:09 1541

原创 【hackerrank】Insertion Sort Advanced Analysis

Insertion Sort is a simple sorting technique which was covered in previous challenges. Sometimes, arrays may be too large for us to wait around for insertion sort to finish. Is there some other way we

2013-12-26 19:38:49 2945 1

第五届华为创新杯编程大赛--块分配问题

2013年华为第五届创新杯编程大赛决赛试题

2013-05-31

c++primer plus第七章到第十三章习题源码

自己做的答案,全部亲自通过编译。从第七章开始,前面几章在网上能下到全部版本的答案,而从第七章开始却没有

2013-03-12

飞凌ok6410开发板使用导读

使用开发板之前,读次文档能够帮助你勾画一个宏观的轮廓,找得到方向,还有一些注意事项。

2012-10-24

飞凌6410裸机调试教程

基于飞凌公司出产的OK6410,ARM11板子的裸机调试教程,比较初级。 是帮助入门开发板的人。

2012-10-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除