diff --git a/solution/0500-0599/0506.Relative Ranks/README.md b/solution/0500-0599/0506.Relative Ranks/README.md index 2f1fa1b09f81b..8dc348d38fa3e 100644 --- a/solution/0500-0599/0506.Relative Ranks/README.md +++ b/solution/0500-0599/0506.Relative Ranks/README.md @@ -97,9 +97,7 @@ class Solution { public String[] findRelativeRanks(int[] score) { int n = score.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i1, i2) -> score[i2] - score[i1]); String[] ans = new String[n]; String[] top3 = new String[] {"Gold Medal", "Silver Medal", "Bronze Medal"}; diff --git a/solution/0500-0599/0506.Relative Ranks/README_EN.md b/solution/0500-0599/0506.Relative Ranks/README_EN.md index 8bb99b92b780c..7abeba13e8be4 100644 --- a/solution/0500-0599/0506.Relative Ranks/README_EN.md +++ b/solution/0500-0599/0506.Relative Ranks/README_EN.md @@ -96,9 +96,7 @@ class Solution { public String[] findRelativeRanks(int[] score) { int n = score.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i1, i2) -> score[i2] - score[i1]); String[] ans = new String[n]; String[] top3 = new String[] {"Gold Medal", "Silver Medal", "Bronze Medal"}; diff --git a/solution/0500-0599/0506.Relative Ranks/Solution.java b/solution/0500-0599/0506.Relative Ranks/Solution.java index 700c854e36bcb..a855b14e5cb57 100644 --- a/solution/0500-0599/0506.Relative Ranks/Solution.java +++ b/solution/0500-0599/0506.Relative Ranks/Solution.java @@ -2,9 +2,7 @@ class Solution { public String[] findRelativeRanks(int[] score) { int n = score.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i1, i2) -> score[i2] - score[i1]); String[] ans = new String[n]; String[] top3 = new String[] {"Gold Medal", "Silver Medal", "Bronze Medal"}; diff --git a/solution/0800-0899/0853.Car Fleet/README.md b/solution/0800-0899/0853.Car Fleet/README.md index fadb1d60e4f77..c8bb9502b2c1e 100644 --- a/solution/0800-0899/0853.Car Fleet/README.md +++ b/solution/0800-0899/0853.Car Fleet/README.md @@ -125,9 +125,7 @@ class Solution { public int carFleet(int target, int[] position, int[] speed) { int n = position.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> position[j] - position[i]); int ans = 0; double pre = 0; diff --git a/solution/0800-0899/0853.Car Fleet/README_EN.md b/solution/0800-0899/0853.Car Fleet/README_EN.md index baba8b025d9bf..29c9d8eef5cd8 100644 --- a/solution/0800-0899/0853.Car Fleet/README_EN.md +++ b/solution/0800-0899/0853.Car Fleet/README_EN.md @@ -117,9 +117,7 @@ class Solution { public int carFleet(int target, int[] position, int[] speed) { int n = position.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> position[j] - position[i]); int ans = 0; double pre = 0; diff --git a/solution/0800-0899/0853.Car Fleet/Solution.java b/solution/0800-0899/0853.Car Fleet/Solution.java index c346687da335c..593a14db56bc7 100644 --- a/solution/0800-0899/0853.Car Fleet/Solution.java +++ b/solution/0800-0899/0853.Car Fleet/Solution.java @@ -2,9 +2,7 @@ class Solution { public int carFleet(int target, int[] position, int[] speed) { int n = position.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> position[j] - position[i]); int ans = 0; double pre = 0; diff --git a/solution/1300-1399/1340.Jump Game V/README.md b/solution/1300-1399/1340.Jump Game V/README.md index 0660b49704759..b51d004488eaa 100644 --- a/solution/1300-1399/1340.Jump Game V/README.md +++ b/solution/1300-1399/1340.Jump Game V/README.md @@ -280,9 +280,7 @@ class Solution { public int maxJumps(int[] arr, int d) { int n = arr.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> arr[i] - arr[j]); int[] f = new int[n]; Arrays.fill(f, 1); diff --git a/solution/1300-1399/1340.Jump Game V/README_EN.md b/solution/1300-1399/1340.Jump Game V/README_EN.md index 96a1c9e3a29e9..d502c5e896373 100644 --- a/solution/1300-1399/1340.Jump Game V/README_EN.md +++ b/solution/1300-1399/1340.Jump Game V/README_EN.md @@ -251,9 +251,7 @@ class Solution { public int maxJumps(int[] arr, int d) { int n = arr.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> arr[i] - arr[j]); int[] f = new int[n]; Arrays.fill(f, 1); diff --git a/solution/1300-1399/1340.Jump Game V/Solution2.java b/solution/1300-1399/1340.Jump Game V/Solution2.java index 7eadbd4bb0a0a..9dd9b724cefe3 100644 --- a/solution/1300-1399/1340.Jump Game V/Solution2.java +++ b/solution/1300-1399/1340.Jump Game V/Solution2.java @@ -2,9 +2,7 @@ class Solution { public int maxJumps(int[] arr, int d) { int n = arr.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> arr[i] - arr[j]); int[] f = new int[n]; Arrays.fill(f, 1); diff --git a/solution/1700-1799/1707.Maximum XOR With an Element From Array/README.md b/solution/1700-1799/1707.Maximum XOR With an Element From Array/README.md index 26dcf2fea57a6..7d844099664f8 100644 --- a/solution/1700-1799/1707.Maximum XOR With an Element From Array/README.md +++ b/solution/1700-1799/1707.Maximum XOR With an Element From Array/README.md @@ -156,9 +156,7 @@ class Solution { Arrays.sort(nums); int n = queries.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> queries[i][1] - queries[j][1]); int[] ans = new int[n]; Trie trie = new Trie(); diff --git a/solution/1700-1799/1707.Maximum XOR With an Element From Array/README_EN.md b/solution/1700-1799/1707.Maximum XOR With an Element From Array/README_EN.md index 48b6e43efcc4e..5bfcb9d83a61c 100644 --- a/solution/1700-1799/1707.Maximum XOR With an Element From Array/README_EN.md +++ b/solution/1700-1799/1707.Maximum XOR With an Element From Array/README_EN.md @@ -156,9 +156,7 @@ class Solution { Arrays.sort(nums); int n = queries.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> queries[i][1] - queries[j][1]); int[] ans = new int[n]; Trie trie = new Trie(); diff --git a/solution/1700-1799/1707.Maximum XOR With an Element From Array/Solution.java b/solution/1700-1799/1707.Maximum XOR With an Element From Array/Solution.java index ddaca27459a9d..7eff272997151 100644 --- a/solution/1700-1799/1707.Maximum XOR With an Element From Array/Solution.java +++ b/solution/1700-1799/1707.Maximum XOR With an Element From Array/Solution.java @@ -35,9 +35,7 @@ public int[] maximizeXor(int[] nums, int[][] queries) { Arrays.sort(nums); int n = queries.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> queries[i][1] - queries[j][1]); int[] ans = new int[n]; Trie trie = new Trie(); diff --git a/solution/2400-2499/2418.Sort the People/README.md b/solution/2400-2499/2418.Sort the People/README.md index a3d891e926c45..7db79d539fe4c 100644 --- a/solution/2400-2499/2418.Sort the People/README.md +++ b/solution/2400-2499/2418.Sort the People/README.md @@ -89,9 +89,7 @@ class Solution { public String[] sortPeople(String[] names, int[] heights) { int n = names.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> heights[j] - heights[i]); String[] ans = new String[n]; for (int i = 0; i < n; ++i) { diff --git a/solution/2400-2499/2418.Sort the People/README_EN.md b/solution/2400-2499/2418.Sort the People/README_EN.md index d4fc8bc793f5a..b015ebe2440a5 100644 --- a/solution/2400-2499/2418.Sort the People/README_EN.md +++ b/solution/2400-2499/2418.Sort the People/README_EN.md @@ -89,9 +89,7 @@ class Solution { public String[] sortPeople(String[] names, int[] heights) { int n = names.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> heights[j] - heights[i]); String[] ans = new String[n]; for (int i = 0; i < n; ++i) { diff --git a/solution/2400-2499/2418.Sort the People/Solution.java b/solution/2400-2499/2418.Sort the People/Solution.java index 1df6c9409a95d..7bc3b7c734b83 100644 --- a/solution/2400-2499/2418.Sort the People/Solution.java +++ b/solution/2400-2499/2418.Sort the People/Solution.java @@ -2,9 +2,7 @@ class Solution { public String[] sortPeople(String[] names, int[] heights) { int n = names.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> heights[j] - heights[i]); String[] ans = new String[n]; for (int i = 0; i < n; ++i) { diff --git a/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/README.md b/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/README.md index 4cc5758dd7d21..3b762a5a7a72a 100644 --- a/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/README.md +++ b/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/README.md @@ -295,9 +295,7 @@ class Solution { int n = nums.length; boolean[] vis = new boolean[n + 2]; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> nums[i] - nums[j]); long ans = 0; for (int i : idx) { diff --git a/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/README_EN.md b/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/README_EN.md index 1ec520193607b..563c05aba70b5 100644 --- a/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/README_EN.md +++ b/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/README_EN.md @@ -293,9 +293,7 @@ class Solution { int n = nums.length; boolean[] vis = new boolean[n + 2]; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> nums[i] - nums[j]); long ans = 0; for (int i : idx) { diff --git a/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/Solution2.java b/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/Solution2.java index 960c61cb37d47..0af4d6500d9a5 100644 --- a/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/Solution2.java +++ b/solution/2500-2599/2593.Find Score of an Array After Marking All Elements/Solution2.java @@ -3,9 +3,7 @@ public long findScore(int[] nums) { int n = nums.length; boolean[] vis = new boolean[n + 2]; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> nums[i] - nums[j]); long ans = 0; for (int i : idx) { diff --git a/solution/2600-2699/2611.Mice and Cheese/README.md b/solution/2600-2699/2611.Mice and Cheese/README.md index 85785a8dbbb89..0e98d863702c9 100644 --- a/solution/2600-2699/2611.Mice and Cheese/README.md +++ b/solution/2600-2699/2611.Mice and Cheese/README.md @@ -105,9 +105,7 @@ class Solution { public int miceAndCheese(int[] reward1, int[] reward2, int k) { int n = reward1.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> reward1[j] - reward2[j] - (reward1[i] - reward2[i])); int ans = 0; for (int i = 0; i < k; ++i) { diff --git a/solution/2600-2699/2611.Mice and Cheese/README_EN.md b/solution/2600-2699/2611.Mice and Cheese/README_EN.md index af96f1dd754e6..814442ac8cc97 100644 --- a/solution/2600-2699/2611.Mice and Cheese/README_EN.md +++ b/solution/2600-2699/2611.Mice and Cheese/README_EN.md @@ -97,9 +97,7 @@ class Solution { public int miceAndCheese(int[] reward1, int[] reward2, int k) { int n = reward1.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> reward1[j] - reward2[j] - (reward1[i] - reward2[i])); int ans = 0; for (int i = 0; i < k; ++i) { diff --git a/solution/2600-2699/2611.Mice and Cheese/Solution.java b/solution/2600-2699/2611.Mice and Cheese/Solution.java index ddcda831b5914..9596e0fc1f6c1 100644 --- a/solution/2600-2699/2611.Mice and Cheese/Solution.java +++ b/solution/2600-2699/2611.Mice and Cheese/Solution.java @@ -2,9 +2,7 @@ class Solution { public int miceAndCheese(int[] reward1, int[] reward2, int k) { int n = reward1.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> reward1[j] - reward2[j] - (reward1[i] - reward2[i])); int ans = 0; for (int i = 0; i < k; ++i) { diff --git a/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/README.md b/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/README.md index 3f09229169241..3e93b629c4543 100644 --- a/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/README.md +++ b/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/README.md @@ -109,9 +109,7 @@ class Solution { public int[] lexicographicallySmallestArray(int[] nums, int limit) { int n = nums.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> nums[i] - nums[j]); int[] ans = new int[n]; for (int i = 0; i < n;) { diff --git a/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/README_EN.md b/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/README_EN.md index 2288ef732c2bd..92bc67681af20 100644 --- a/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/README_EN.md +++ b/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/README_EN.md @@ -107,9 +107,7 @@ class Solution { public int[] lexicographicallySmallestArray(int[] nums, int limit) { int n = nums.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> nums[i] - nums[j]); int[] ans = new int[n]; for (int i = 0; i < n;) { diff --git a/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/Solution.java b/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/Solution.java index 1138b649ab386..ba0e141e4b1af 100644 --- a/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/Solution.java +++ b/solution/2900-2999/2948.Make Lexicographically Smallest Array by Swapping Elements/Solution.java @@ -2,9 +2,7 @@ class Solution { public int[] lexicographicallySmallestArray(int[] nums, int limit) { int n = nums.length; Integer[] idx = new Integer[n]; - for (int i = 0; i < n; ++i) { - idx[i] = i; - } + Arrays.setAll(idx, i -> i); Arrays.sort(idx, (i, j) -> nums[i] - nums[j]); int[] ans = new int[n]; for (int i = 0; i < n;) {