mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-22 15:53:50 +08:00
Add the chapter of Graph (#303)
* Update the chapter graph * Update the chapter graph * Update the chapter graph * Update the chapter graph
This commit is contained in:
@ -20,6 +20,33 @@ class Trunk {
|
||||
};
|
||||
|
||||
public class PrintUtil {
|
||||
|
||||
/**
|
||||
* Print a matrix (Array)
|
||||
* @param <T>
|
||||
* @param matrix
|
||||
*/
|
||||
public static <T> void printMatrix(T[][] matrix) {
|
||||
System.out.println("[");
|
||||
for (T[] row : matrix) {
|
||||
System.out.println(" " + row + ",");
|
||||
}
|
||||
System.out.println("]");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a matrix (List)
|
||||
* @param <T>
|
||||
* @param matrix
|
||||
*/
|
||||
public static <T> void printMatrix(List<List<T>> matrix) {
|
||||
System.out.println("[");
|
||||
for (List<T> row : matrix) {
|
||||
System.out.println(" " + row + ",");
|
||||
}
|
||||
System.out.println("]");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a linked list
|
||||
* @param head
|
||||
|
Reference in New Issue
Block a user