(int[] nums, int pivot)
| 1 | class Solution { |
| 2 | public int[] pivotArray(int[] nums, int pivot) { |
| 3 | int lCount=0; |
| 4 | int gCount=0; |
| 5 | int pCount=0; |
| 6 | for(int num : nums){ |
| 7 | if(num < pivot){ |
| 8 | lCount++; |
| 9 | }else if(num > pivot){ |
| 10 | gCount++; |
| 11 | }else{ |
| 12 | pCount++; |
| 13 | } |
| 14 | } |
| 15 | int i=0; |
| 16 | int j=lCount; |
| 17 | int k=lCount + pCount; |
| 18 | int res[] = new int[nums.length]; |
| 19 | for(int num : nums){ |
| 20 | if(num < pivot){ |
| 21 | res[i] = num; |
| 22 | i++; |
| 23 | }else if(num > pivot){ |
| 24 | res[k] = num; |
| 25 | k++; |
| 26 | }else{ |
| 27 | res[j] = num; |
| 28 | j++; |
| 29 | } |
| 30 | } |
| 31 | return res; |
| 32 | } |
| 33 | } |
nothing calls this directly
no outgoing calls
no test coverage detected