Skip to content

Commit

Permalink
make test cases pass for insertion sort list
Browse files Browse the repository at this point in the history
  • Loading branch information
DefiPanda committed Sep 10, 2014
1 parent 722cc13 commit 93a8f22
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Insertion Sort List.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
class Solution:
def isListAllSorted(self, head):
current = head
while current and current.next:
if current.val > current.next.val:
return False
current = current.next
return True

def insertionSortList(self, head):
if head == None:
if head == None or self.isListAllSorted(head):
return head
dummy = ListNode(-9223372036854775808)
dummy.next = head
Expand Down

0 comments on commit 93a8f22

Please sign in to comment.