mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-25 05:22:39 +08:00
style: enable ConstantName
in checkstyle (#5139)
Co-authored-by: Maria Paszkiewicz SCC <maria.paszkiewicz@kit.edu>
This commit is contained in:
@ -5,14 +5,14 @@ import java.util.Scanner;
|
||||
|
||||
public class LCA {
|
||||
|
||||
private static final Scanner scanner = new Scanner(System.in);
|
||||
private static final Scanner SCANNER = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) {
|
||||
// The adjacency list representation of a tree:
|
||||
ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
|
||||
|
||||
// v is the number of vertices and e is the number of edges
|
||||
int v = scanner.nextInt(), e = v - 1;
|
||||
int v = SCANNER.nextInt(), e = v - 1;
|
||||
|
||||
for (int i = 0; i < v; i++) {
|
||||
adj.add(new ArrayList<Integer>());
|
||||
@ -21,8 +21,8 @@ public class LCA {
|
||||
// Storing the given tree as an adjacency list
|
||||
int to, from;
|
||||
for (int i = 0; i < e; i++) {
|
||||
to = scanner.nextInt();
|
||||
from = scanner.nextInt();
|
||||
to = SCANNER.nextInt();
|
||||
from = SCANNER.nextInt();
|
||||
|
||||
adj.get(to).add(from);
|
||||
adj.get(from).add(to);
|
||||
@ -38,7 +38,7 @@ public class LCA {
|
||||
dfs(adj, 0, -1, parent, depth);
|
||||
|
||||
// Inputting the two vertices whose LCA is to be calculated
|
||||
int v1 = scanner.nextInt(), v2 = scanner.nextInt();
|
||||
int v1 = SCANNER.nextInt(), v2 = SCANNER.nextInt();
|
||||
|
||||
// Outputting the LCA
|
||||
System.out.println(getLCA(v1, v2, depth, parent));
|
||||
|
Reference in New Issue
Block a user