| 1 | public class PowerNonDecreasing { |
| 2 | static int makePowerNonDecreasing(int[] power,int n) |
| 3 | { |
| 4 | if(n==1) |
| 5 | return 0; |
| 6 | int sum=0; |
| 7 | for(int i=0;i<n-1;i++){ |
| 8 | if(power[i]>power[i+1]){ |
| 9 | int val=power[i]-power[i+1]; |
| 10 | sum += val; |
| 11 | for(int j=i+1;j<n;j++){ |
| 12 | power[j]=power[j]+val; |
| 13 | } // inner loop end |
| 14 | } // if loop end |
| 15 | } // outer loop end |
| 16 | return sum; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | // Time complexity is always less than O(n2) |
nothing calls this directly
no outgoing calls
no test coverage detected