## Tuesday, April 17, 2018

### Beat 99.95% of submitted solutions for Merge Two Sorted Linked Lists

Yes, I did it again. Simple enough.

```# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
def mergeTwoLists(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
cur=None
while l1 is not None or l2 is not None:
if  l1 is not None and l2 is not None and l1.val<l2.val:
l1=l1.next
elif l1 is not None and l2 is not None and l1.val>l2.val:
l2=l2.next
elif l1 is None and l2 is not None:
l2=l2.next
else:
l1=l1.next
elif l1 is not None and l2 is not None and l1.val<l2.val:
cur.next=l1
l1=l1.next
cur=cur.next
elif  l1 is not None and l2 is not None and l1.val>l2.val:
cur.next=l2
l2=l2.next
cur=cur.next
elif  l1 is None and l2 is not None:
cur.next=l2
l2=l2.next
cur=cur.next
else:
cur.next=l1
l1=l1.next
cur=cur.next

```

## Monday, April 9, 2018

### Beat 95.56% of python submissions

Good result. I'm happy.

```# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
"""
:type n: int
:rtype: ListNode
"""
count=0
tmp=list()
while cur is not None:
# if count>n:
#     break
tmp.append(cur)
cur=cur.next
count+=1

if count==1 and n==1:
return None

if n==1:
tmp[len(tmp)-n-1].next=None

if n==len(tmp):

if n>0:
tmp[len(tmp)-n-1].next=tmp[len(tmp)-n+1]

if __name__ =='__main__':
s=Solution()
class ListNode:
def __init__(self, x):
self.val = x
self.next = None

while cur.next is not None:
cur=cur.next
cur.next=ListNode(val)

while cur is not None:
print (cur.val)
cur=cur.next

ln=ListNode(1)
s.removeNthFromEnd(ln,5)

```

## Monday, March 12, 2018

### Beat 100% of python3 submissions

Yes! I did it.
Here is simple code that  gives me  performance  described on picture above.

```class powxy:
def pow(self, x, n):
if n == 0.0:
return 1
if n < 0:
n = -n
x = 1/x
if n % 2 == 0:
return self.pow(x*x, int(n/2))
return x*self.pow(x*x, int(n/2))
```