12 2015 档案

摘要:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文
posted @ 2015-12-30 14:50 eversliver 阅读(248) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2015-12-28 21:02 eversliver 阅读(248) 评论(0) 推荐(0)
摘要:闲来无聊,前两天看到一篇关于算法实现的文章。里面又关于图的各种算法介绍,正好上学期还学过图论,现在还记得一点点,先来实现个prim算法:表示图的文件的内容大体上是这样的: 1 2.0 1.0 1.0 2 3.0 1.0 1.0 3 4.0 1.0 1.0 4 5.... 阅读全文
posted @ 2015-12-27 22:24 eversliver 阅读(5200) 评论(0) 推荐(0)
摘要:Givennballoons, indexed from0ton-1. Each balloon is painted with a number on it represented by arraynums. You are asked to burst all the balloons. If ... 阅读全文
posted @ 2015-12-27 21:37 eversliver 阅读(873) 评论(0) 推荐(1)
摘要:Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam... 阅读全文
posted @ 2015-12-26 20:48 eversliver 阅读(310) 评论(0) 推荐(0)
摘要:Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a ... 阅读全文
posted @ 2015-12-25 21:37 eversliver 阅读(283) 评论(0) 推荐(0)
摘要:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2015-12-24 14:54 eversliver 阅读(688) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2015-12-23 22:54 eversliver 阅读(296) 评论(0) 推荐(0)
摘要:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.将链表从右... 阅读全文
posted @ 2015-12-22 22:09 eversliver 阅读(251) 评论(0) 推荐(0)
摘要:There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[... 阅读全文
posted @ 2015-12-22 10:11 eversliver 阅读(683) 评论(0) 推荐(0)
摘要:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2015-12-17 22:53 eversliver 阅读(334) 评论(0) 推荐(1)
摘要:单例模式十分的常见也很常用,Boost库中就有单例的泛型实现,Qt中,可以利用原子指针来实现一个单例模式: 1 class SingleTon{ 2 public: 3 static SingleTon &getInstance(void) 4 { 5 //双重检测加... 阅读全文
posted @ 2015-12-16 22:42 eversliver 阅读(9167) 评论(0) 推荐(1)
摘要:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.类似于归并2个链表,暴力一点的方法就是,每取出一个list就与以前的list归并返回merge后list,知... 阅读全文
posted @ 2015-12-15 22:09 eversliver 阅读(392) 评论(0) 推荐(0)
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文
posted @ 2015-12-12 11:57 eversliver 阅读(338) 评论(0) 推荐(0)
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.求出0,1矩阵中的最大矩形区域:DP问题,可以使用数组记下当前行位... 阅读全文
posted @ 2015-12-08 22:25 eversliver 阅读(619) 评论(0) 推荐(0)
摘要:Given a 2d grid map of'1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent ... 阅读全文
posted @ 2015-12-08 20:21 eversliver 阅读(657) 评论(0) 推荐(0)
摘要:Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with ... 阅读全文
posted @ 2015-12-02 20:59 eversliver 阅读(427) 评论(0) 推荐(0)
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2015-12-01 20:18 eversliver 阅读(272) 评论(0) 推荐(0)