Skip to content

Commit 96ca744

Browse files
add notes for a utils method
1 parent d3cf905 commit 96ca744

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/com/fishercoder/common/utils/CommonUtils.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ public static <T> void printArray_generic_type(T[] nums) {
2424
public static void main(String... strings) {
2525
Integer[] nums = new Integer[]{1, 2, 3, 4, 5};
2626
printArray_generic_type(nums);
27-
CommonUtils.printListList(convertLeetCode2DStringArrayInputIntoJavaArray("[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]"));
27+
String input1 = "[\"zDkA\",\"GfAj\",\"lt\"],[\"GfAj\",\"rtupD\",\"og\",\"l\"],[\"rtupD\",\"IT\",\"jGcew\",\"ZwFqF\"],[\"og\",\"yVobt\",\"EjA\",\"piUyQ\"],[\"IT\",\"XFlc\",\"W\",\"rB\"],[\"l\",\"GwQg\",\"shco\",\"Dub\",\"KwgZq\"],[\"oXMG\",\"uqe\"],[\"sNyV\",\"WbrP\"]";
28+
String input2 = "[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]";
29+
CommonUtils.printListList(convertLeetCode2DStringArrayInputIntoJavaArray(input1));
30+
CommonUtils.printListList(convertLeetCode2DStringArrayInputIntoJavaArray(input2));
2831
CommonUtils.print(convertLeetCode1DStringArrayInputIntoJavaArray("[\"abcsi\",\"abyzjgj\",\"advz\",\"ag\",\"agkgdkob\",\"agpr\",\"ail\"]"));
2932
CommonUtils.print2DIntArray(convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray("[448,931,123,345],[889],[214,962],[576,746,897]"));
3033
}
@@ -387,6 +390,11 @@ public static int[][] convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray(S
387390

388391
public static List<List<String>> convertLeetCode2DStringArrayInputIntoJavaArray(String input) {
389392
/**
393+
* How to copy LeetCode 2-d String array into this method:
394+
* 1. remove the beginning and ending quotes;
395+
* 2. put double quotes into this method parameter;
396+
* 3. copy the input into the double quotes.
397+
*
390398
* LeetCode 2-d array input usually comes like this: each row could have different length
391399
* [["A","B"],["C"],["B","C"],["D"]]
392400
* The expected input for this method is: "[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]"

0 commit comments

Comments
 (0)