One Pass solution in Python3 | O(n) time | O(1) space


#1
class Solution:
    # @param A : head node of linked list
    # @return the head node in the linked list
    def solve(self, A):
        node = ListNode(0)
        start = end = node
        while A:
            nextA = A.next
            if A.val == 0:           # Inserting at head
                nextS = start
                start = A
                start.next = nextS
            else:                    # Inserting at tail
                end.next = A
                end = end.next
                end.next = None
            A = nextA
        return start.next