Skip to content

Commit

Permalink
Merge pull request SocialfiPanda#7 from resorcap/master
Browse files Browse the repository at this point in the history
Create Excel Sheet Column Number.py
  • Loading branch information
SocialfiPanda committed Mar 9, 2015
2 parents 428fe2a + b3e2a56 commit dcd640a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
7 changes: 7 additions & 0 deletions Excel Sheet Column Number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Solution:
def titleToNumber(self, s):
num = 0
for i in s:
num *= 26
num += ord(i) - 64
return num
5 changes: 5 additions & 0 deletions Largest Number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Solution:
def largestNumber(self, num):
num = [str(x) for x in num]
num.sort(cmp = lambda x, y: cmp(y+x, x+y))
return ''.join(num).lstrip('0') or '0'
19 changes: 10 additions & 9 deletions Remove Nth Node From End of List.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
class Solution:
def removeNthFromEnd(self, head, n):
fast, slow, prev = head, head, None
while n > 0:
fast, n = fast.next, n - 1
while fast != None:
fast, slow, prev = fast.next, slow.next, slow
if prev == None:
return head.next
prev.next = prev.next.next
return head
dummy = ListNode(-1)
dummy.next = head
left, right = dummy, dummy
while n:
right, n = right.next, n-1
while right.next:
right = right.next
left = left.next
left.next = left.next.next
return dummy.next
2 changes: 1 addition & 1 deletion Reverse Words in a String.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Solution:
def reverseWords(self, s):
return " ".join(filter(lambda x: x, reversed(s.split(" "))))
return " ".join(filter(None, reversed(s.split(" "))))

0 comments on commit dcd640a

Please sign in to comment.