Skip to content

Commit 8878878

Browse files
authored
Updated spotless
1 parent 505c02e commit 8878878

File tree

1,739 files changed

+6742
-5410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,739 files changed

+6742
-5410
lines changed

build.gradle.kts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
kotlin("jvm") version "2.0.21"
33
jacoco
44
id("org.sonarqube") version "5.1.0.4882"
5-
id("com.diffplug.spotless") version "6.12.0"
5+
id("com.diffplug.spotless") version "6.21.0"
66
`maven-publish`
77
}
88

@@ -52,9 +52,14 @@ spotless {
5252
kotlin {
5353
encoding("UTF-8")
5454
target("**/src/**/*.kt")
55-
ktlint("0.43.0").userData(mapOf(
56-
"max_line_length" to "120"
57-
))
55+
ktlint("0.50.0").editorConfigOverride(
56+
mapOf(
57+
"max_line_length" to "120",
58+
"indent_size" to "4",
59+
"ktlint_standard_package-name" to "disabled",
60+
"ktlint_standard_comment-wrapping" to "disabled"
61+
)
62+
)
5863
toggleOffOn()
5964
trimTrailingWhitespace()
6065
endWithNewline()

pom-central.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<plugin>
110110
<groupId>org.jetbrains.dokka</groupId>
111111
<artifactId>dokka-maven-plugin</artifactId>
112-
<version>1.9.20</version>
112+
<version>2.0.0-Beta</version>
113113
<executions>
114114
<execution>
115115
<phase>prepare-package</phase>

src/main/kotlin/com_github_leetcode/Employee.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ class Employee(
66
/** the importance value of this employee */
77
var importance: Int,
88
/** the id of direct subordinates */
9-
var subordinates: List<Int> = listOf()
9+
var subordinates: List<Int> = listOf(),
1010
)

src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring/Solution.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ class Solution {
1919
var lpsCenter = 0
2020
var lpsRadius = 0
2121
for (i in newStr.indices) {
22-
dp[i] = if (friendCenter + friendRadius > i) Math.min(
23-
dp[friendCenter * 2 - i],
24-
friendCenter + friendRadius - i
25-
) else 1
22+
dp[i] = if (friendCenter + friendRadius > i) {
23+
Math.min(
24+
dp[friendCenter * 2 - i],
25+
friendCenter + friendRadius - i,
26+
)
27+
} else {
28+
1
29+
}
2630
while (i + dp[i] < newStr.size && i - dp[i] >= 0 && newStr[i + dp[i]] == newStr[i - dp[i]]) {
2731
dp[i]++
2832
}

src/main/kotlin/g0001_0100/s0010_regular_expression_matching/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Solution {
3131
i,
3232
j - 2,
3333
s,
34-
p
34+
p,
3535
)
3636
}
3737
} else {

src/main/kotlin/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Solution {
1919
nums: String,
2020
letters: Array<String>,
2121
curr: StringBuilder,
22-
ans: MutableList<String>
22+
ans: MutableList<String>,
2323
) {
2424
if (curr.length == nums.length) {
2525
ans.add(curr.toString())

src/main/kotlin/g0001_0100/s0023_merge_k_sorted_lists/Solution.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class Solution {
1919
fun mergeKLists(lists: Array<ListNode>): ListNode? {
2020
return if (lists.isEmpty()) {
2121
null
22-
} else mergeKLists(lists, 0, lists.size)
22+
} else {
23+
mergeKLists(lists, 0, lists.size)
24+
}
2325
}
2426

2527
private fun mergeKLists(lists: Array<ListNode>, leftIndex: Int, rightIndex: Int): ListNode? {

src/main/kotlin/g0001_0100/s0030_substring_with_concatenation_of_all_words/Solution.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Solution {
2020
// move a word's length each time
2121
var j = i
2222
while (j + window <= s.length) {
23-
2423
// get the subStr
2524
val subStr = s.substring(j, j + window)
2625
val map: MutableMap<String, Int> = HashMap()

src/main/kotlin/g0001_0100/s0040_combination_sum_ii/Solution.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Solution {
1919
target: Int,
2020
start: Int,
2121
sums: MutableList<List<Int>>,
22-
sum: LinkedList<Int>
22+
sum: LinkedList<Int>,
2323
) {
2424
if (target == 0) {
2525
// make a deep copy of the current combination
@@ -28,7 +28,6 @@ class Solution {
2828
}
2929
var i = start
3030
while (i < candidates.size && target >= candidates[i]) {
31-
3231
// If candidate[i] equals candidate[i-1], then solutions for i is subset of
3332
// solution of i-1
3433
if (i == start || i > start && candidates[i] != candidates[i - 1]) {

src/main/kotlin/g0001_0100/s0046_permutations/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Solution {
1919
nums: IntArray,
2020
finalResult: MutableList<List<Int>>,
2121
currResult: MutableList<Int>,
22-
used: BooleanArray
22+
used: BooleanArray,
2323
) {
2424
if (currResult.size == nums.size) {
2525
finalResult.add(ArrayList(currResult))

src/main/kotlin/g0001_0100/s0048_rotate_image/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Solution {
1313
intArrayOf(i, j),
1414
intArrayOf(j, n - 1 - i),
1515
intArrayOf(n - 1 - i, n - 1 - j),
16-
intArrayOf(n - 1 - j, i)
16+
intArrayOf(n - 1 - j, i),
1717
)
1818
var t = matrix[pos[0][0]][pos[0][1]]
1919
for (k in 1 until pos.size) {

src/main/kotlin/g0001_0100/s0049_group_anagrams/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Solution {
1212
ch.sort()
1313
val temp = String(ch)
1414
hm.computeIfAbsent(
15-
temp
15+
temp,
1616
) { _: String? -> ArrayList() }
1717
hm.getValue(temp).add(s)
1818
}

src/main/kotlin/g0001_0100/s0050_powx_n/Solution.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class Solution {
2323
}
2424
return if (n < 0) {
2525
1.0 / res
26-
} else res
26+
} else {
27+
res
28+
}
2729
}
2830
}

src/main/kotlin/g0001_0100/s0052_n_queens_ii/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Solution {
1717
row: BooleanArray,
1818
col: BooleanArray,
1919
diagonal: BooleanArray,
20-
antiDiagonal: BooleanArray
20+
antiDiagonal: BooleanArray,
2121
): Int {
2222
if (r == n) {
2323
return 1

src/main/kotlin/g0001_0100/s0079_word_search/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Solution {
1111
word: String,
1212
index: Int,
1313
x: Int,
14-
y: Int
14+
y: Int,
1515
): Boolean {
1616
if (index == word.length) {
1717
return true
@@ -40,7 +40,7 @@ class Solution {
4040
fun exist(board: Array<CharArray>, word: String): Boolean {
4141
val visited = Array(board.size) {
4242
BooleanArray(
43-
board[0].size
43+
board[0].size,
4444
)
4545
}
4646
for (i in board.indices) {

src/main/kotlin/g0001_0100/s0084_largest_rectangle_in_histogram/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Solution {
3838
maxOfThreeNums(
3939
largestArea(a, start, minInd),
4040
a[minInd] * (limit - start),
41-
largestArea(a, minInd + 1, limit)
41+
largestArea(a, minInd + 1, limit),
4242
)
4343
}
4444
}

src/main/kotlin/g0001_0100/s0093_restore_ip_addresses/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Solution {
1717
'.' +
1818
octets[2] +
1919
'.' +
20-
octets[3]
20+
octets[3],
2121
)
2222
} else if (count < 4 && pos < 12) {
2323
var octet = 0

src/main/kotlin/g0001_0100/s0097_interleaving_string/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Solution {
1818
i1: Int,
1919
i2: Int,
2020
i3: Int,
21-
cache: Array<Array<Boolean?>>
21+
cache: Array<Array<Boolean?>>,
2222
): Boolean {
2323
if (cache[i1][i2] != null) {
2424
return cache[i1][i2]!!

src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree/Solution.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class Solution {
3030
}
3131
return if (root.`val` <= left || root.`val` >= right) {
3232
false
33-
} else solve(root.left, left, root.`val`.toLong()) && solve(root.right, root.`val`.toLong(), right)
33+
} else {
34+
solve(root.left, left, root.`val`.toLong()) && solve(root.right, root.`val`.toLong(), right)
35+
}
3436
}
3537
}

src/main/kotlin/g0001_0100/s0100_same_tree/Solution.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class Solution {
2020
return if (n != null && m != null) {
2121
if (n.`val` != m.`val`) {
2222
false
23-
} else trav(n.left, m.left) && trav(n.right, m.right)
23+
} else {
24+
trav(n.left, m.left) && trav(n.right, m.right)
25+
}
2426
} else {
2527
n == null && m == null
2628
}

src/main/kotlin/g0101_0200/s0101_symmetric_tree/Solution.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class Solution {
2020
fun isSymmetric(root: TreeNode?): Boolean {
2121
return if (root == null) {
2222
true
23-
} else helper(root.left, root.right)
23+
} else {
24+
helper(root.left, root.right)
25+
}
2426
}
2527

2628
private fun helper(leftNode: TreeNode?, rightNode: TreeNode?): Boolean {
@@ -29,6 +31,8 @@ class Solution {
2931
}
3032
return if (leftNode.`val` != rightNode.`val`) {
3133
false
32-
} else helper(leftNode.left, rightNode.right) && helper(leftNode.right, rightNode.left)
34+
} else {
35+
helper(leftNode.left, rightNode.right) && helper(leftNode.right, rightNode.left)
36+
}
3337
}
3438
}

src/main/kotlin/g0101_0200/s0112_path_sum/Solution.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Solution {
2222
}
2323
return if (targetSum == root.`val` && root.left == null && root.right == null) {
2424
true
25-
} else hasPathSum(root.left, targetSum - root.`val`) || hasPathSum(root.right, targetSum - root.`val`)
25+
} else {
26+
hasPathSum(root.left, targetSum - root.`val`) || hasPathSum(root.right, targetSum - root.`val`)
27+
}
2628
}
2729
}

src/main/kotlin/g0101_0200/s0113_path_sum_ii/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Solution {
3131
al: ArrayList<Int>,
3232
sum: Int,
3333
targetSum: Int,
34-
root: TreeNode?
34+
root: TreeNode?,
3535
) {
3636
var sum = sum
3737
if (root == null) {

src/main/kotlin/g0101_0200/s0120_triangle/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Solution {
2727
triangle[row][col] +
2828
Math.min(
2929
dfs(triangle, dp, row + 1, col),
30-
dfs(triangle, dp, row + 1, col + 1)
30+
dfs(triangle, dp, row + 1, col + 1),
3131
)
3232
)
3333
dp[row][col] = sum

src/main/kotlin/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package g0101_0200.s0123_best_time_to_buy_and_sell_stock_iii
55
class Solution {
66
fun maxProfit(prices: IntArray): Int {
77
val n = prices.size
8-
if (n <2) {
8+
if (n < 2) {
99
return 0
1010
}
1111
val a = IntArray(n) { 0 }

src/main/kotlin/g0101_0200/s0126_word_ladder_ii/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Solution {
3232
if (isLadder(word, next)) {
3333
// construct the reverse graph from endWord
3434
val reverseLadders = reverse.computeIfAbsent(
35-
next
35+
next,
3636
) { _: String? -> HashSet() }
3737
reverseLadders.add(word)
3838
if (endWord == next) {
@@ -71,7 +71,7 @@ class Solution {
7171
beginWord: String,
7272
graph: Map<String, MutableSet<String>>,
7373
ans: MutableList<List<String>>,
74-
path: MutableSet<String>
74+
path: MutableSet<String>,
7575
) {
7676
val next = graph[endWord] ?: return
7777
for (word in next) {

src/main/kotlin/g0101_0200/s0128_longest_consecutive_sequence/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Solution {
2222
if (num == lastNum) {
2323
continue
2424
}
25-
length ++
25+
length++
2626
if (num - lastNum > 1) {
2727
length = 1
2828
}

src/main/kotlin/g0101_0200/s0134_gas_station/Solution.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class Solution {
2424
}
2525
return if (sumGas < sumCost) {
2626
-1
27-
} else result
27+
} else {
28+
result
29+
}
2830
}
2931
}

src/main/kotlin/g0101_0200/s0140_word_break_ii/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Solution {
1818
wordSet: Set<String>,
1919
index: Int,
2020
sb: StringBuilder,
21-
result: MutableList<String>
21+
result: MutableList<String>,
2222
) {
2323
if (index == s.length) {
2424
if (sb[sb.length - 1] == ' ') {

src/main/kotlin/g0101_0200/s0150_evaluate_reverse_polish_notation/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Solution {
88
"/" to { a, b -> a / b },
99
"*" to { a, b -> a * b },
1010
"+" to { a, b -> a + b },
11-
"-" to { a, b -> a - b }
11+
"-" to { a, b -> a - b },
1212
)
1313
fun evalRPN(tokens: Array<String>): Int {
1414
val stack = ArrayDeque<String>()

src/main/kotlin/g0101_0200/s0154_find_minimum_in_rotated_sorted_array_ii/Solution.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class Solution {
77
fun findMin(nums: IntArray): Int {
88
return if (nums.isEmpty()) {
99
0
10-
} else find(0, nums.size - 1, nums)
10+
} else {
11+
find(0, nums.size - 1, nums)
12+
}
1113
}
1214

1315
private fun find(left: Int, right: Int, nums: IntArray): Int {

src/main/kotlin/g0101_0200/s0155_min_stack/MinStack.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ class MinStack() {
99
private val stack: ArrayDeque<Pair<Int, Int>> = ArrayDeque()
1010

1111
fun push(x: Int) {
12-
val min: Int = if (stack.isEmpty()) x
13-
else getMin()
12+
val min: Int = if (stack.isEmpty()) {
13+
x
14+
} else {
15+
getMin()
16+
}
1417
stack.addLast(x to minOf(min, x))
1518
}
1619

src/main/kotlin/g0201_0300/s0201_bitwise_and_of_numbers_range/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Solution {
4141
-0x10,
4242
-0x8,
4343
-0x4,
44-
-0x2
44+
-0x2,
4545
)
4646
}
4747
}

src/main/kotlin/g0201_0300/s0210_course_schedule_ii/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Solution {
3434
private fun buildGraph(
3535
numCourses: Int,
3636
prerequisites: Array<IntArray>,
37-
indegrees: IntArray
37+
indegrees: IntArray,
3838
): List<List<Int>> {
3939
val graph = List(numCourses) { mutableListOf<Int>() }
4040
for ((cur, prev) in prerequisites) {

0 commit comments

Comments
 (0)