# FB phone screen

```

This is just a simple shared plaintext pad, with no execution capabilities.

When you know what language you would like to use for your interview,
simply choose it from the dropdown in the top bar.

def main():
print 123

# input: 5->6->3 8->4->2
# output: 1->4->0->5

def __init__(self, v):
self.val =  v
self.next =  None

# convert linked list to a number
# convert the result to a linked list

def solve(L1, L2):

res = 0
while h:
res = res*10 + h.val
h = h.next

return res

s = str(n)
L = len(s)
i = 0
while i&lt;L:
h = h.next
i += 1

return dummy.next

return res

# input: 5->6->3 8->4->2
# output: 1->4->0->5

# cycle 1
res = 0
h - > 5
res = res*10 + h.val = 5

# cycle 2
res = 5
h -> 6
----
res = 5*10 + 6 = 56

# cycle 3
res = 56
h -> 3
---
res = 56*10 +3 = 563

return 563

# 842
n = 1405

s = str(n) = '1405'
L = len(n) = 4

i = 0..3
dummy = ListNode(None)
h = dummy

# i = 0
h.next = node
h = h.next

# i = 1
int(s[i=1]) = 4
node = ListNode(4)
h.next = node
h = h.next

dummy -> 1 -> 4 (head) -> None

....

dummy -> 1 -> 4 -> 0 -> 5 -> None
return dummy.next

aba, abba abax

# input: str
# output: bool

abax
l, r = 0, len(s)-1
s[l] == s[r]

if not same:
s1 = s[:l] + s[l+1:]
s2 = s[:r] + s[r+1:]

return s1[::-1] == s1 or s2[::-1] == s2

def isPalindromeWith1Deletion(s):

## O(n)
l, r = 0, len(s) - 1

while l&lt;r:

if s[l] != s[r]:
s1 = s[:l] + s[l+1:] # O(n)
s2 = s[:r] + s[r+1:] # O(n)
return s1[::-1] == s1 or s2[::-1] == s2 # 2 * O(n)
l, r = l+1, r-1

return True

# abax
l = 0 (a), r = 3 (x)

s1 = 'bax'
s2 = 'aba' # True

# abxax
l = 0 (a), r = 4 (x)

s1 = 'bxax' # False
s2 = 'abxa' # False

return False

def isPalindromeWith1Deletion(s):

## o(n*n)
L = len(s)
for i in range(i):
r = s[:i] + s[i+1:]
if r == r[::-1]:
return True

return False

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172

Welcome to Facebook! This is just a simple shared plaintext pad, with no execution capabilities. When you know what language you would like to use for your interview,simply choose it from the dropdown in the top bar. Enjoy your interview! def main():    print 123    # input: 5->6->3 8->4->2# output: 1->4->0->5 class LinkNode:    def __init__(self, v):        self.val =  v        self.next =  None # convert linked list to a number# convert the result to a linked list    def solve(L1, L2):            def linkedlist2number(h):                res = 0        while h:            res = res*10 + h.val            h = h.next                    return res            def number2linkedlist(n):                dummy = h = LinkNode(None)        s = str(n)        L = len(s)        i = 0        while i&lt;L:            h.next = LinkNode(int(s[i]))             h = h.next            i += 1                    return dummy.next        n1 = linkedlist2number(L1)    n2 = linkedlist2number(L2)    res = number2linkedlist(n1+n2)        return res                # input: 5->6->3 8->4->2# output: 1->4->0->5 # linkedlist2number # cycle 1res = 0h - > 5res = res*10 + h.val = 5 # cycle 2res = 5h -> 6----res = 5*10 + 6 = 56 # cycle 3res = 56h -> 3---res = 56*10 +3 = 563 return 563 # 842n = 1405 # number2linkedlists = str(n) = '1405'L = len(n) = 4 i = 0..3dummy = ListNode(None)h = dummy # i = 0node = LinkNode(int(s[i]))h.next = nodeh = h.next dummy -> 1(head) -> None # i = 1int(s[i=1]) = 4node = ListNode(4)h.next = nodeh = h.next dummy -> 1 -> 4 (head) -> None        .... dummy -> 1 -> 4 -> 0 -> 5 -> Nonereturn dummy.next  aba, abba abax        # input: str# output: bool        abaxl, r = 0, len(s)-1 s[l] == s[r] if not same:    s1 = s[:l] + s[l+1:]    s2 = s[:r] + s[r+1:]        return s1[::-1] == s1 or s2[::-1] == s2   def isPalindromeWith1Deletion(s):        ## O(n)    l, r = 0, len(s) - 1        while l&lt;r:                if s[l] != s[r]:            s1 = s[:l] + s[l+1:] # O(n)            s2 = s[:r] + s[r+1:] # O(n)            return s1[::-1] == s1 or s2[::-1] == s2 # 2 * O(n)         l, r = l+1, r-1            return True # abaxl = 0 (a), r = 3 (x) s1 = 'bax's2 = 'aba' # True # abxaxl = 0 (a), r = 4 (x) s1 = 'bxax' # Falses2 = 'abxa' # False return False      def isPalindromeWith1Deletion(s):            ## o(n*n)    L = len(s)    for i in range(i):        r = s[:i] + s[i+1:]        if r == r[::-1]:            return True        return False

```