Hi, guys, I want to solve it with the following idea, but it hits the overflow. Can some one help me to fix it?

Here is the idea:

step 1: map 3 colors (0\1\2) to three prime number, say 2\3\5.

step 2: go through the array and multiply all the element up, for example: `A = [0, 1, 2, 1, 2, 1, 0, 2]`

maps to `A' = [2,3,5,3,5,3,2,5]`

, then the multiplied number is `multiSum = 2*3*5*3*5*3*2*5 = 13500`

.

step 3: divide multiSum with 2 repectly untill the multiSum can not divide by 2 and push back it to A, then do this with 3 and5. when multiSum = 13500:

divide by 2:13500/2 = 67500 --> A[0] = 0; 6750/2= 3375-->A[1] = 0

then it can not divide by 2.go to 3. do it repectly until multiSum =1.

Here is the code:

```
class Solution {
public:
void sortColors(int A[], int n) {
int multiSum = 1;
int primeNum[3] = {2,3,5};
for (int i = 0 ; i<n; ++i){
multiSum *= primeNum[A[i]];
}
int index = 0;
for (int j = 0; j<3; ++j){
while(multiSum%primeNum[j] == 0){
multiSum /= primeNum[j];
A[index] = j;
++index;
}
}
}
};
```