自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(40)
  • 收藏
  • 关注

原创 LeetCode 370. Range Addition

原题网址:https://leetcode.com/problems/range-addition/Assume you have an array of length n initialized with all 0's and are given k update operations.Each operation is represented as a triplet: 

2016-06-30 02:52:03 3619

原创 LeetCode 368. Largest Divisible Subset

原题网址:https://leetcode.com/problems/largest-divisible-subset/Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfie

2016-06-29 05:05:01 709

原创 LeetCode 369. Plus One Linked List(链表加1)

原题网址:https://leetcode.com/problems/plus-one-linked-list/Given a non-negative number represented as a singly linked list of digits, plus one to the number.The digits are stored such that the most

2016-06-29 02:38:17 2247

原创 LeetCode 367. Valid Perfect Square

原题网址:https://leetcode.com/problems/valid-perfect-square/Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in

2016-06-27 09:23:08 362

原创 HackerRank [Algo] Matrix Rotation

原题网址:https://www.hackerrank.com/challenges/matrix-rotation-algoYou are given a 2D matrix, a, of dimension MxN and a positive integer R. You have to rotate the matrix R times and print th

2016-06-26 13:09:39 730

原创 LintCode Url Parser

原题网址:http://www.lintcode.com/en/problem/url-parser/Parse a html page, extract the Urls in it.Hint: use regex to parse html.Have you met this question in a real interview? Yes

2016-06-26 09:25:49 1203

原创 LeetCode 366. Find Leaves of Binary Tree

原题网址:https://leetcode.com/problems/find-leaves-of-binary-tree/Given a binary tree, find all leaves and then remove those leaves. Then repeat the previous steps until the tree is empty.Example:

2016-06-26 01:49:00 2682

原创 LintCode Inverted Index

原题网址:http://www.lintcode.com/en/problem/inverted-index/Create an inverted index with given documents. NoticeEnsure that data does not include punctuation.Have you met thi

2016-06-25 05:55:23 959

原创 LeetCode 365. Water and Jug Problem

原题网址:https://leetcode.com/problems/water-and-jug-problem/You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine wheth

2016-06-25 05:28:10 1615

原创 最大半径问题

一个长度为n的数组,从中选取k个数字,若定义这k个数字的半径为排序后相邻两个数字之间的最小间隔,则k个数字所能达到的最大半径是多少?如果k = 1,则半径为无穷大。假设k > 0。方法一:深度优先搜索。class SolutionDFS { private int max = 0; public SolutionDFS(int[] nums, int k) { find(n

2016-06-25 03:09:28 670

原创 LeetCode 361

原题网址:https://leetcode.com/problems/bomb-enemy/Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bo

2016-06-25 02:51:59 813

原创 HackRank Cut the sticks

原题网址:https://www.hackerrank.com/challenges/cut-the-sticksYou are given  sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that a

2016-06-24 06:56:05 863

原创 LintCode Mini Cassandra

原题网址:http://www.lintcode.com/en/problem/mini-cassandra/Cassandra is a NoSQL storage. The structure has two-level keys.Level 1: raw_key. The same as hash_key or shard_key.Level 2: column_

2016-06-24 06:35:38 1869

原创 LintCode Consistent Hashing II(一致性哈希算法II)

原题网址:http://www.lintcode.com/en/problem/consistent-hashing-ii/在 Consistent Hashing I 中我们介绍了一个比较简单的一致性哈希算法,这个简单的版本有两个缺陷:增加一台机器之后,数据全部从其中一台机器过来,这一台机器的读负载过大,对正常的服务会造成影响。当增加到3台机器的时候,每台服务器的负载量不

2016-06-24 06:19:02 2463

原创 LeetCode 364. Nested List Weight Sum II

原题网址:https://leetcode.com/problems/nested-list-weight-sum-ii/Given a nested list of integers, return the sum of all integers in the list weighted by their depth.Each element is either an int

2016-06-24 00:16:31 2757

原创 HackerRank Service Lane

原题网址:https://www.hackerrank.com/challenges/service-laneCalvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants

2016-06-23 10:45:41 699

原创 HackerRank Breadth First Search: Shortest Reach

原题网址:https://www.hackerrank.com/challenges/bfsshortreachGiven an undirected graph consisting of  nodes (labelled 1 to N) where a specific given node  represents the start position and

2016-06-23 08:08:43 955

原创 HackerRank Fibonacci Modified

原题网址:https://www.hackerrank.com/challenges/fibonacci-modifiedA series is defined in the following manner:Given the nth and (n+1)th terms, the (n+2)th can be computed by the following r

2016-06-23 08:04:40 662

原创 LintCode Memcache

原题网址:http://www.lintcode.com/en/problem/memcache/Implement a memcache which support the following features:get(curtTime, key). Get the key's value, return 2147483647 if key does not exis

2016-06-23 07:20:16 882

原创 LintCode Consistent Hashing(一致性哈希算法)

原题网址:http://www.lintcode.com/en/problem/consistent-hashing/一般的数据库进行horizontal shard的方法是指,把 id 对 数据库服务器总数 n 取模,然后来得到他在哪台机器上。这种方法的缺点是,当数据继续增加,我们需要增加数据库服务器,将 n 变为 n+1 时,几乎所有的数据都要移动,这就造成了不 consist

2016-06-23 05:16:18 2469

原创 LeetCode 363. Max Sum of Rectangle No Larger Than K(矩阵和)

原题网址:https://leetcode.com/problems/max-sum-of-sub-matrix-no-larger-than-k/Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is

2016-06-23 02:55:19 4001

原创 LeetCode 362. Design Hit Counter(计数器)

原题网址:https://leetcode.com/problems/design-hit-counter/Design a hit counter which counts the number of hits received in the past 5 minutes.Each function accepts a timestamp parameter (in seco

2016-06-23 00:45:16 2326

原创 LintCode Find Peak Element II(查找峰值II)

原题网址:http://www.lintcode.com/en/problem/find-peak-element-ii/There is an integer matrix which has the following features:The numbers in adjacent positions are different.The matrix has n rows

2016-06-21 03:27:29 2969

原创 LintCode Find Peak Element(查找峰值)

原题网址:http://www.lintcode.com/en/problem/find-peak-element/There is an integer array which has the following features:The numbers in adjacent positions are different.A[0] A[A.length - 1].

2016-06-21 01:38:59 1402

原创 LintCode Backpack III(背包III)

原题网址:http://www.lintcode.com/en/problem/backpack-iii/Given n kind of items with size Ai and value Vi(each item has an infinite number available) and a backpack with size m. What's the maximum

2016-06-21 01:05:37 1249

原创 LintCode Backpack II(背包II)

原题网址:http://www.lintcode.com/en/problem/backpack-ii/Given n items with size Ai and value Vi, and a backpack with size m. What's the maximum value can you put into the backpack? Notice

2016-06-21 00:55:11 546

原创 LintCode Backpack(背包)

原题网址:http://www.lintcode.com/en/problem/backpack/Given n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack? NoticeYou can not divid

2016-06-21 00:29:43 899

原创 图论相关问题(提纲)

一、欧拉图(七桥问题)七桥问题:给定一个图,能否从某个顶点出发,不重复地遍历所有的边,并且回到起点。欧拉图:图G是欧拉图的充要条件是,G连通且没有奇定顶点。二、一笔画问题。一个图能一笔画成的充要条件是,图G连通且奇顶点数为0或2.一笔画算法参考:http://blog.csdn.net/jmspan/article/details/51279044三、哈密尔

2016-06-18 01:07:44 1243

原创 LeetCode 360. Sort Transformed Array(计算函数)

原题网址:https://leetcode.com/problems/sort-transformed-array/Given a sorted array of integers nums and integer values a, b and c. Apply a function of the form f(x) = ax2 + bx + c to each element 

2016-06-17 11:42:23 1278

原创 LeetCode 359. Logger Rate Limiter(日志漏桶)

原题网址:https://leetcode.com/problems/logger-rate-limiter/Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not p

2016-06-17 01:24:29 4080

原创 LeetCode 354. Russian Doll Envelopes(信封包装)

原题网址:https://leetcode.com/problems/russian-doll-envelopes/You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and on

2016-06-16 06:39:42 2589

原创 LeetCode 356. Line Reflection(线反射)

原题网址:https://leetcode.com/problems/line-reflection/Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given set of points.Example 1:Given po

2016-06-16 02:43:49 2109

原创 LeetCode 353. Design Snake Game(设计贪吃蛇游戏)

原题网址:https://leetcode.com/problems/design-snake-game/Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the gam

2016-06-16 02:41:06 4843

原创 LeetCode 352. Data Stream as Disjoint Intervals(数据流区间)

原题网址:https://leetcode.com/problems/data-stream-as-disjoint-intervals/Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of dis

2016-06-16 01:11:36 1561

原创 LeetCode 355. Design Twitter(设计Twitter)

原题网址:https://leetcode.com/problems/design-twitter/Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in

2016-06-15 04:49:48 968

原创 LeetCode 358. Rearrange String k Distance Apart(字符间隔)

原题网址:https://leetcode.com/problems/rearrange-string-k-distance-apart/Given a non-empty string str and an integer k, rearrange the string such that the same characters are at least distance k fro

2016-06-15 03:27:55 4742

原创 LeetCode 357. Count Numbers with Unique Digits(计算无重复数字)

原题网址:https://leetcode.com/problems/count-numbers-with-unique-digits/Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.Example:Given n = 2, return 91. (

2016-06-15 02:04:36 1369

原创 关于图的常用算法——Dijkstra单源最短路径、Floyd多源最短路径、Prim和Kruskal最小生成树算法

Dijkstra最短路径算法是计算某一点到其它点的最短距离的算法。Floyd算法是用来计算图中所有点之间的最短距离,可参考:http://developer.51cto.com/art/201403/433874.htm最小生成树(Minimium Spanning Tree)如果要在N个城市中铺设网络,每个城市之间的网络建设成本不同,如何找到一个建设方案,使得

2016-06-10 15:29:52 5121

原创 LeetCode 42. Trapping Rain Water

原题网址:https://leetcode.com/problems/trapping-rain-water/Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap aft

2016-06-09 02:22:13 765

原创 LeetCode 324. Wiggle Sort II(摇摆排序)

原题网址:https://leetcode.com/problems/wiggle-sort-ii/Given an unsorted array nums, reorder it such that nums[0] nums[2] .Example:(1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is

2016-06-05 00:58:45 1455

空空如也

空空如也

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

TA关注的人

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