---
# System prepended metadata

title: Question 1

---


# Question 1
```
Given an array of random positive numbers, move all the zeroes to the left of the array. 

Conditions: 
1) has to be done in place ( space-constrained, ie. cannot allocate a new array)
2) the order of non-zero elements on the right do not matter

Input :  arr[] = {0, 1, 2, 5, 0, 3, 0, 3}; 
Output : arr[] = {0, 0, 0, 2, 1, 3, 3, 5};
```

```javascript / ruby / go / python
// Write your solution here

// O(n) 10 * 1 = 10 seconds
// O(n^2) 10 * 10 * 1 = 100 seconds
let arr = [0, 1, i>0, 2, 0, 5, 3, 3] 

let random = (arrs) => {
        
        let temp = 0;
        for (let j = 0; j < arrs.length-1; j++) {
            if (arrs[j] != 0) {
                temp = i
            }
        }
    
    return arrs;
}

console.log(random(arr))


```

# Question 2
```
//        1 <---- root
//     /     \
//    2       3
//   / \     / \
//  4   5   6   7
//
// write a function to print tree by level 
// ie. print "1","2","3","4","5","6","7"....
```



```javascript / ruby / go / python
// Write your solution here
class Node {
    var value : string
    var left : Node
    var right : Node
}


function printTreeByLevel(root: Node) {
    //...
    for (let i = root;)
}

























```

