Solutions for Zeros, Ones and Twos

    • @kristeencoupp91
    • @Ethan, submitted in Python 3, achived 100% score
    def solve( a): 
        arr_size = len(a) 
        lo = 0
        hi = arr_size - 1
        mid = 0
        while mid <= hi: 
            if a[mid] == 0: 
                a[lo], a[mid] = a[mid], a[lo] 
                lo = lo + 1
                mid = mid + 1
            elif a[mid] == 1: 
                mid = mid + 1
            else: 
                a[mid], a[hi] = a[hi], a[mid]  
                hi = hi - 1
        return a 
    
    # Function to print array 
    def printArray( a): 
        for k in a: 
            return k