@@ -30,12 +30,12 @@ tags:
3030<pre >
3131<strong >Input:</strong > nums = [1,3,1,1,2]
3232<strong >Output:</strong > [5,0,3,4,0]
33- <strong >Explanation:</strong >
34- When i = 0, nums[0] == nums[2] and nums[0] == nums[3]. Therefore, arr[0] = |0 - 2| + |0 - 3| = 5.
33+ <strong >Explanation:</strong >
34+ When i = 0, nums[0] == nums[2] and nums[0] == nums[3]. Therefore, arr[0] = |0 - 2| + |0 - 3| = 5.
3535When i = 1, arr[1] = 0 because there is no other index with value 3.
36- When i = 2, nums[2] == nums[0] and nums[2] == nums[3]. Therefore, arr[2] = |2 - 0| + |2 - 3| = 3.
37- When i = 3, nums[3] == nums[0] and nums[3] == nums[2]. Therefore, arr[3] = |3 - 0| + |3 - 2| = 4.
38- When i = 4, arr[4] = 0 because there is no other index with value 2.
36+ When i = 2, nums[2] == nums[0] and nums[2] == nums[3]. Therefore, arr[2] = |2 - 0| + |2 - 3| = 3.
37+ When i = 3, nums[3] == nums[0] and nums[3] == nums[2]. Therefore, arr[3] = |3 - 0| + |3 - 2| = 4.
38+ When i = 4, arr[4] = 0 because there is no other index with value 2.
3939
4040</pre >
4141
@@ -215,7 +215,7 @@ function distance(nums: number[]): number[] {
215215 }
216216 }
217217 return ans ;
218- };
218+ }
219219```
220220
221221#### Rust
0 commit comments