Skip to content

Commit b0b2f0e

Browse files
committed
git
1 parent 8b9d037 commit b0b2f0e

File tree

63 files changed

+483
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+483
-141
lines changed

STYLEGUIDE.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,7 @@ across different programming languages while adhering to LeetCode's conventions.
466466

467467
```java
468468
List<Integer>[] graph = new List[n];
469-
470-
for (int i = 0; i < n; ++i)
471-
graph[i] = new ArrayList<>();
469+
Arrays.setAll(graph, i -> new ArrayList<>());
472470

473471
for (int[] edge : edges) {
474472
final int u = edge[0];

solutions/1042. Flower Planting With No Adjacent/1042.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ class Solution {
22
public int[] gardenNoAdj(int n, int[][] paths) {
33
int[] ans = new int[n]; // ans[i] := 1, 2, 3, or 4
44
List<Integer>[] graph = new List[n];
5-
6-
for (int i = 0; i < n; ++i)
7-
graph[i] = new ArrayList<>();
5+
Arrays.setAll(graph, i -> new ArrayList<>());
86

97
for (int[] path : paths) {
108
final int u = path[0] - 1;

solutions/1059. All Paths from Source Lead to Destination/1059.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ class Solution {
44
public boolean leadsToDestination(int n, int[][] edges, int source, int destination) {
55
List<Integer>[] graph = new List[n];
66
State[] states = new State[n];
7-
8-
for (int i = 0; i < n; ++i)
9-
graph[i] = new ArrayList<>();
7+
Arrays.setAll(graph, i -> new ArrayList<>());
108

119
for (int[] edge : edges) {
1210
final int u = edge[0];

solutions/1129. Shortest Path with Alternating Colors/1129.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ public int[] shortestAlternatingPaths(int n, int[][] redEdges, int[][] blueEdges
88
List<Pair<Integer, Color>>[] graph = new List[n];
99
// [(u, prevColor)]
1010
Queue<Pair<Integer, Color>> q = new ArrayDeque<>(List.of(new Pair<>(0, Color.INIT)));
11-
12-
for (int i = 0; i < n; ++i)
13-
graph[i] = new ArrayList<>();
11+
Arrays.setAll(graph, i -> new ArrayList<>());
1412

1513
for (int[] edge : redEdges) {
1614
final int u = edge[0];

solutions/1136. Parallel Courses/1136-2.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ class Solution {
22
public int minimumSemesters(int n, int[][] relations) {
33
List<Integer>[] graph = new List[n];
44
int[] inDegrees = new int[n];
5-
6-
for (int i = 0; i < n; ++i)
7-
graph[i] = new ArrayList<>();
5+
Arrays.setAll(graph, i -> new ArrayList<>());
86

97
// Build the graph.
108
for (int[] relation : relations) {

solutions/1136. Parallel Courses/1136.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ public int minimumSemesters(int n, int[][] relations) {
66
State[] states = new State[n];
77
int[] depth = new int[n];
88
Arrays.fill(depth, 1);
9-
10-
for (int i = 0; i < n; ++i)
11-
graph[i] = new ArrayList<>();
9+
Arrays.setAll(graph, i -> new ArrayList<>());
1210

1311
for (int[] relation : relations) {
1412
final int u = relation[0] - 1;

solutions/1192. Critical Connections in a Network/1192.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ class Solution {
22
public List<List<Integer>> criticalConnections(int n, List<List<Integer>> connections) {
33
List<List<Integer>> ans = new ArrayList<>();
44
List<Integer>[] graph = new List[n];
5-
6-
for (int i = 0; i < n; ++i)
7-
graph[i] = new ArrayList<>();
5+
Arrays.setAll(graph, i -> new ArrayList<>());
86

97
for (List<Integer> connection : connections) {
108
final int u = connection.get(0);

solutions/1319. Number of Operations to Make Network Connected/1319.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ public int makeConnected(int n, int[][] connections) {
77
int numOfConnected = 0;
88
List<Integer>[] graph = new List[n];
99
Set<Integer> seen = new HashSet<>();
10-
11-
for (int i = 0; i < n; ++i)
12-
graph[i] = new ArrayList<>();
10+
Arrays.setAll(graph, i -> new ArrayList<>());
1311

1412
for (int[] connection : connections) {
1513
final int u = connection[0];

solutions/1443. Minimum Time to Collect All Apples in a Tree/1443.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
class Solution {
22
public int minTime(int n, int[][] edges, List<Boolean> hasApple) {
33
List<Integer>[] graph = new List[n];
4-
5-
for (int i = 0; i < n; ++i)
6-
graph[i] = new ArrayList<>();
4+
Arrays.setAll(graph, i -> new ArrayList<>());
75

86
for (int[] edge : edges) {
97
final int u = edge[0];

solutions/1466. Reorder Routes to Make All Paths Lead to the City Zero/1466.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
class Solution {
22
public int minReorder(int n, int[][] connections) {
33
List<Integer>[] graph = new List[n];
4-
5-
for (int i = 0; i < n; ++i)
6-
graph[i] = new ArrayList<>();
4+
Arrays.setAll(graph, i -> new ArrayList<>());
75

86
for (int[] connection : connections) {
97
final int u = connection[0];

0 commit comments

Comments
 (0)