Add coding exercises for Facebook interviews
Add attempts at solving coding problems to Briefcase.
This commit is contained in:
parent
d2d772e43e
commit
aa66d9b83d
66 changed files with 2994 additions and 0 deletions
22
scratch/facebook/linked_list.py
Normal file
22
scratch/facebook/linked_list.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class Node(object):
|
||||
def __init__(self, value=None, next=None):
|
||||
self.value = value
|
||||
self.next = next
|
||||
|
||||
def __repr__(self):
|
||||
result = []
|
||||
node = self
|
||||
while node:
|
||||
result.append(str(node.value))
|
||||
node = node.next
|
||||
return 'LinkedList({xs})'.format(xs=', '.join(result))
|
||||
|
||||
def from_list(xs):
|
||||
head = Node(xs[0])
|
||||
node = head
|
||||
for x in xs[1:]:
|
||||
node.next = Node(x)
|
||||
node = node.next
|
||||
return head
|
||||
|
||||
list = from_list(['A', 'B', 'C'])
|
||||
Loading…
Add table
Add a link
Reference in a new issue