Skip to content

Commit 8f3d190

Browse files
committed
Brain fu*k
1 parent 363eced commit 8f3d190

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

data-structures/src/main/java/com/thealgorithm/graph/MakeLexicographicallySmallestArrayBySwappingElements.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ public int[] lexicographicallySmallestArray(int[] nums, int limit) {
6363
}
6464

6565
public static void main(String[] args){
66-
System.out.println(new Solution().lexicographicallySmallestArray(new int[] {1, 4, 2, 1, 4, 2, 1}, 3));
66+
System.out.println(Arrays.toString(new Solution().lexicographicallySmallestArray(new int[]{1, 4, 2, 1, 4, 2, 1}, 1)));
6767
}
6868
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.thealgorithm.tierIII;
2+
3+
public class Pattern_0 {
4+
public static void main(String[] args) {
5+
printLevelGoNext(1, 50);
6+
}
7+
8+
public static void printLevelGoNext(int level, int n) {
9+
if (level > n) {
10+
return;
11+
} else {
12+
printC('\n', 1);
13+
}
14+
15+
printLevel(level, n);
16+
printLevelGoNext(level + 1, n);
17+
}
18+
19+
private static void printLevel(int level, int n) {
20+
printSpaces(level, n);
21+
printStars((level << 1) - 1);
22+
}
23+
24+
private static void printC(char c, int n) {
25+
if (n > 0) {
26+
System.out.print(c);
27+
printC(c, n - 1);
28+
}
29+
}
30+
31+
private static void printStars(int n) {
32+
printC('*', n);
33+
}
34+
35+
private static void printSpaces(int level, int n) {
36+
printC(' ', (n - level));
37+
}
38+
}

0 commit comments

Comments
 (0)