Sept. 10, 2015 Study again the back tracking algorithm using recursive solution, rat in maze, a classical problem. Made a few of mistakes through the practice, one is how to use two dimension array, another one is that "not all return path returns va…
H-Index I Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N pap…
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false. Note:You may assume the string contains onl…
2014-05-06 00:17 题目链接 原题: Given a -D matrix represents the room, obstacle and guard like the following ( is room, B->obstacle, G-> Guard): B G G B calculate the steps from a room to nearest Guard and set the matrix, like this B G G B Write the algor…
http://codility.com/demo/take-sample-test/genomicrangequery 这题有点意思.一开始以为是RMQ或者线段树,但这样要O(n*logn).考虑到只有四种字符,可以用数组记录每个字符i之前出现过几次.二,查询区间是闭区间,所以要处理off by one的问题. // you can also use includes, for example: // #include <algorithm> vector<int> solutio…
http://codility.com/demo/take-sample-test/maxcounters 简单题.注意要记录两个max,一个是最大值,一个是已经生效的最大值. // you can also use includes, for example: // #include <algorithm> vector<int> solution(int N, vector<int> &A) { // write your code in C++98 int…
−Table of Contents Journey to the Center of the Linux Kernel: Traffic Control, Shaping and QoS 1 Introduction 2 Motivation 3 The basics of Traffic Control 3.1 First contact 3.2 Netfilter MARK 3.3 Two classes in a tree 3.4 Connecting the marks to the…
今天发现又出了lesson 3... 不过题目都很简单…… (1) Min-avg-slice 给定一个长度为n的整数数组,找到一个连续的子数组,数组元素的平均值最小. 数据范围N [1..10^5],数组元素范围[-10^4, +10^4]. 要求复杂度: 时间O(N),空间O(N). 分析: 就是求最小值……因为如果拉进别的数,平均值会增大,干嘛搞成这样,空间可以O(1).说得神乎其神的…… 代码: // you can also use includes, for example: //…