2.3Implementanalgorithmtodeleteanodeinthemiddleofasinglelinkedlist,givenonlyaccesstothatnode.EXAMPLEInput:thenode‘c’fromthelinkedlista->b->c->d->eResult:nothingisreturned,butthenewlinkedlistlookslikea->b->d->eItseemscannotdirecltydele..
分类:
其他好文 时间:
2014-11-24 08:45:39
阅读次数:
106
2.5Givenacircularlinkedlist,implementanalgorithmwhichreturnsnodeatthebeginningoftheloop.DEFINITIONCircularlinkedlist:A(corrupt)linkedlistinwhichanode’snextpointerpointstoanearliernode,soastomakealoopinthelinkedlist.EXAMPLEinput:A->B->C->D->E-&g..
分类:
其他好文 时间:
2014-11-24 08:44:00
阅读次数:
122
2.4Youhavetwonumbersrepresentedbyalinkedlist,whereeachnodecontainsasingledigit.Thedigitsarestoredinreverseorder,suchthatthe1’sdigitisattheheadofthelist.Writeafunctionthataddsthetwonumbersandreturnsthesumasalinkedlist.EXAMPLEInput:(3->1->5)+(5->9-&..
分类:
其他好文 时间:
2014-11-24 08:43:11
阅读次数:
120
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Have you met this question in a real interview?Analy...
分类:
其他好文 时间:
2014-11-22 07:03:11
阅读次数:
192
Loop List is very common in interview. This article we give a more strict shortstatement about its solving.One method to check if there's a loop in a ...
分类:
其他好文 时间:
2014-11-22 01:58:08
阅读次数:
201
Python有很多有用有趣的内置函数,比如reduce,map,filter,lambda,zip等。已经写过了lambda和zip相关的博客。继续写关于reduce,map,filter。
Map
首先用help方法看一下map的具体用法。
help(map)
# result
Help on built-in function map in module __buil...
分类:
编程语言 时间:
2014-11-15 10:11:19
阅读次数:
289
Python 中的lambda函数也叫匿名函数,即,没有具体的名称。lambda的主题是一个表达式,而不是一个代码块,仅仅能在lambda表达式中封装有限的逻辑。
我们拿正常的定义函数的方式来做比较:
def f(x):
return x**2
print f(4)
# result
16
用lambda可以这样写:
g = lambda x : x**2
print...
分类:
编程语言 时间:
2014-11-13 19:01:35
阅读次数:
248
三目运算符,是c语言的重要组成部分。条件运算符是唯一有三个操作数的运算符,又称为三元运算符。
在c语言风格的语言中,三元操作符的形式如下:
? :
但是在python中并没有这样的操作符,在python 2.5之前,可以用如下的方式表示三元运算符
(X, Y)[C]
其中C为条件,如果C不成立,那么元祖中的第一个元素X被返回,如果C成立,那么返回第二个元素Y。 ...
分类:
编程语言 时间:
2014-11-13 16:45:33
阅读次数:
235
1. abstract classabstract class can have anything a normal class can have plus abstract methodpublic abstract class Test11 { public int a; priva...
分类:
编程语言 时间:
2014-11-09 07:29:55
阅读次数:
154
Java Interview Questions + some logic questions at the end. Basics:Q1: What happens when the following program executes?class A{public void a(){b();}p...
分类:
其他好文 时间:
2014-10-29 18:57:31
阅读次数:
184