Skip to content

Commit fcc53c4

Browse files
committed
update
1 parent e5fcede commit fcc53c4

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/main/java/com/leetcode/matrix/MatrixQuiz.java renamed to src/main/java/com/leetcode/matrix/MatrixOne.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import java.util.ArrayList;
44

5-
public class MatrixQuiz {
5+
public class MatrixOne {
66

77
public void setZeroes(int[][] matrix) {
88

@@ -54,7 +54,7 @@ public static void main(String[] args) {
5454
//int[][] matrix = {{1,1,1},{1,0,1},{1,1,1}};
5555
// int[][] matrix = {{0,1,2,0},{3,4,5,2},{1,3,1,5}};
5656
int[][] matrix = {{1, 0}};
57-
new MatrixQuiz().setZeroes(matrix);
57+
new MatrixOne().setZeroes(matrix);
5858
for (int[] row : matrix) {
5959
System.out.print("[ ");
6060
for (int element : row) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.leetcode.recursion;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class RecursionOneS {
7+
8+
9+
public static void main(String[] args) {
10+
String s = "abc";
11+
RecursionOneS recursionOneS = new RecursionOneS();
12+
List<String> result = new ArrayList<>();
13+
recursionOneS.permutate(s, "", result);
14+
for (String ele : result) {
15+
System.out.println(ele);
16+
}
17+
}
18+
19+
private void permutate(String s, String prefix, List<String> result) {
20+
21+
if (s.isEmpty()) {
22+
result.add(prefix);
23+
}
24+
for (int i = 0; i < s.length(); i++) {
25+
permutate(s.substring(0, i) + s.substring(i + 1), prefix + String.valueOf(s.charAt(i)), result);
26+
}
27+
28+
}
29+
}

0 commit comments

Comments
 (0)