fix45 codingbat solution

Solutions on MaxInterview for fix45 codingbat solution by the best coders in the world

showing results for - "fix45 codingbat solution"
Orla
15 Aug 2019
1public int[] fix45(int[] nums) {
2  for (int i=0;i<nums.length;i++){
3    if (nums[i]==4){
4      int temp=nums[i+1];
5      nums[i+1]=143;
6      for (int j=0;j<nums.length;j++){
7        if (nums[j]==5){
8          nums[j]=temp;
9        }
10      }
11      
12    }
13  }
14  for (int i=0;i< nums.length;i++){
15      if (nums[i]==143){
16       nums[i]=5;
17      }
18  }
19  return nums;
20}
21/// Thank You