上一页 1 2 3 4 5 6 7 8 ··· 29 下一页
摘要: 比较典型的一个题目,easy,不过可以有许多实现方式。这里用的方式是每次pop完成之后再将stack2中的内容立即倒回stack1中。但是其他的实现也可以不是这样,可以是需要push的时候检查再,如果内容在stack2中,这时候将其倒回在进行push。这里采取第一种比较笨的方法,代码如下所示: 1 ... 阅读全文
posted @ 2016-01-05 22:40 eversliver 阅读(218) 评论(0) 推荐(0) 编辑
摘要: Given apatternand a stringstr, find ifstrfollows the same pattern.Herefollowmeans a full match, such that there is a bijection between a letter inpatt... 阅读全文
posted @ 2016-01-03 21:57 eversliver 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 在做表达式处理的时候,逆波兰表示法还是很有用的。比如说一个式子(A+B)*C+D-(E-F)这样一个式子可以简单的用逆波兰表示法表示成:AB+C*D+EF--,这样就去掉了表达式中的所有的括号。一个表达式的逻辑处理也更简单了,下面会举一个例子,先占一个坑。 阅读全文
posted @ 2016-01-02 22:55 eversliver 阅读(324) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(222) 评论(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 阅读(224) 评论(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 阅读(5092) 评论(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 阅读(824) 评论(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 阅读(288) 评论(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 阅读(258) 评论(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 阅读(631) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 29 下一页