Skip to content

Commit 7a64938

Browse files
authored
Improved mysql tasks
1 parent fe66e08 commit 7a64938

File tree

50 files changed

+169
-168
lines changed

Some content is hidden

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

50 files changed

+169
-168
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ package g0201_0300.s0212_word_search_ii
66
@Suppress("NAME_SHADOWING")
77
class Solution {
88
private var root: Tree? = null
9-
fun findWords(board: Array<CharArray>, words: Array<String?>): List<String> {
10-
if (board.size < 1 || board[0].size < 1) {
9+
10+
fun findWords(board: Array<CharArray>, words: Array<String>): List<String> {
11+
if (board.isEmpty() || board[0].isEmpty()) {
1112
return emptyList()
1213
}
1314
root = Tree()
1415
for (word in words) {
15-
Tree.addWord(root, word!!)
16+
Tree.addWord(root, word)
1617
}
1718
val collected: MutableList<String> = ArrayList()
1819
for (i in board.indices) {

src/test/kotlin/g0101_0200/s0175_combine_two_tables/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal class MysqlTest {
3434
@Test
3535
@Throws(SQLException::class, FileNotFoundException::class)
3636
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
37-
dataSource.getConnection().use { connection ->
37+
dataSource.connection.use { connection ->
3838
connection.createStatement().use { statement ->
3939
statement.executeQuery(
4040
BufferedReader(

src/test/kotlin/g0201_0300/s0212_word_search_ii/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class SolutionTest {
1313
charArrayOf('i', 'h', 'k', 'r'),
1414
charArrayOf('i', 'f', 'l', 'v'),
1515
)
16-
val words = arrayOf<String?>("oath", "pea", "eat", "rain")
16+
val words = arrayOf<String>("oath", "pea", "eat", "rain")
1717
val expected: MutableList<String> = ArrayList()
1818
expected.add("oath")
1919
expected.add("eat")
@@ -23,7 +23,7 @@ internal class SolutionTest {
2323
@Test
2424
fun findWords2() {
2525
val board = arrayOf(charArrayOf('a', 'b'), charArrayOf('c', 'd'))
26-
val words = arrayOf<String?>("abcb")
26+
val words = arrayOf<String>("abcb")
2727
assertThat(Solution().findWords(board, words), equalTo(emptyList()))
2828
}
2929
}

src/test/kotlin/g0201_0300/s0262_trips_and_users/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal class MysqlTest {
5353
@Test
5454
@Throws(SQLException::class, FileNotFoundException::class)
5555
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
56-
dataSource.getConnection().use { connection ->
56+
dataSource.connection.use { connection ->
5757
connection.createStatement().use { statement ->
5858
statement.executeQuery(
5959
BufferedReader(

src/test/kotlin/g0501_0600/s0511_game_play_analysis_i/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal class MysqlTest {
3434
@Test
3535
@Throws(SQLException::class, FileNotFoundException::class)
3636
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
37-
dataSource.getConnection().use { connection ->
37+
dataSource.connection.use { connection ->
3838
connection.createStatement().use { statement ->
3939
statement.executeQuery(
4040
BufferedReader(

src/test/kotlin/g0501_0600/s0550_game_play_analysis_iv/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal class MysqlTest {
3939
@Test
4040
@Throws(SQLException::class, FileNotFoundException::class)
4141
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
42-
dataSource.getConnection().use { connection ->
42+
dataSource.connection.use { connection ->
4343
connection.createStatement().use { statement ->
4444
statement.executeQuery(
4545
BufferedReader(

src/test/kotlin/g0501_0600/s0584_find_customer_referee/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal class MysqlTest {
2929
@Test
3030
@Throws(SQLException::class, FileNotFoundException::class)
3131
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
32-
dataSource.getConnection().use { connection ->
32+
dataSource.connection.use { connection ->
3333
connection.createStatement().use { statement ->
3434
statement.executeQuery(
3535
BufferedReader(

src/test/kotlin/g0601_0700/s0602_friend_requests_ii_who_has_the_most_friends/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class MysqlTest {
3131
@Test
3232
@Throws(SQLException::class, FileNotFoundException::class)
3333
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
34-
dataSource.getConnection().use { connection ->
34+
dataSource.connection.use { connection ->
3535
connection.createStatement().use { statement ->
3636
statement.executeQuery(
3737
BufferedReader(

src/test/kotlin/g0601_0700/s0607_sales_person/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ internal class MysqlTest {
4949
@Test
5050
@Throws(SQLException::class, FileNotFoundException::class)
5151
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
52-
dataSource.getConnection().use { connection ->
52+
dataSource.connection.use { connection ->
5353
connection.createStatement().use { statement ->
5454
statement.executeQuery(
5555
BufferedReader(

src/test/kotlin/g0601_0700/s0610_triangle_judgement/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal class MysqlTest {
2727
@Test
2828
@Throws(SQLException::class, FileNotFoundException::class)
2929
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
30-
dataSource.getConnection().use { connection ->
30+
dataSource.connection.use { connection ->
3131
connection.createStatement().use { statement ->
3232
statement.executeQuery(
3333
BufferedReader(

src/test/kotlin/g0601_0700/s0619_biggest_single_number/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class MysqlTest {
3131
@Test
3232
@Throws(SQLException::class, FileNotFoundException::class)
3333
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
34-
dataSource.getConnection().use { connection ->
34+
dataSource.connection.use { connection ->
3535
connection.createStatement().use { statement ->
3636
statement.executeQuery(
3737
BufferedReader(

src/test/kotlin/g1101_1200/s1145_binary_tree_coloring_game/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import org.junit.jupiter.api.Test
88
internal class SolutionTest {
99
@Test
1010
fun btreeGameWinningMove() {
11-
val root = TreeNode.create(mutableListOf<Int?>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
11+
val root = TreeNode.create(mutableListOf<Int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
1212
assertThat(Solution().btreeGameWinningMove(root, 11, 3), equalTo(true))
1313
}
1414

1515
@Test
1616
fun btreeGameWinningMove2() {
17-
val root = TreeNode.create(mutableListOf<Int?>(1, 2, 3))
17+
val root = TreeNode.create(mutableListOf<Int>(1, 2, 3))
1818
assertThat(Solution().btreeGameWinningMove(root, 3, 1), equalTo(false))
1919
}
2020
}

src/test/kotlin/g2301_2400/s2356_number_of_unique_subjects_taught_by_each_teacher/MysqlTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal class MysqlTest {
3838
@Test
3939
@Throws(SQLException::class, FileNotFoundException::class)
4040
fun testScript(@EmbeddedDatabase dataSource: DataSource) {
41-
dataSource.getConnection().use { connection ->
41+
dataSource.connection.use { connection ->
4242
connection.createStatement().use { statement ->
4343
statement.executeQuery(
4444
BufferedReader(

src/test/kotlin/g2401_2500/s2468_split_message_based_on_limit/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class SolutionTest {
1010
assertThat(
1111
Solution().splitMessage("this is really a very awesome message", 9),
1212
equalTo(
13-
arrayOf<String?>(
13+
arrayOf<String>(
1414
"thi<1/14>",
1515
"s i<2/14>",
1616
"s r<3/14>",
@@ -34,7 +34,7 @@ internal class SolutionTest {
3434
fun splitMessage2() {
3535
assertThat(
3636
Solution().splitMessage("short message", 15),
37-
equalTo(arrayOf<String?>("short mess<1/2>", "age<2/2>")),
37+
equalTo(arrayOf<String>("short mess<1/2>", "age<2/2>")),
3838
)
3939
}
4040
}

src/test/kotlin/g2801_2900/s2809_minimum_time_to_make_array_sum_at_most_x/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ internal class SolutionTest {
88
@Test
99
fun minimumTime() {
1010
assertThat(
11-
Solution().minimumTime(mutableListOf<Int?>(1, 2, 3), mutableListOf<Int?>(1, 2, 3), 4),
11+
Solution().minimumTime(mutableListOf<Int>(1, 2, 3), mutableListOf<Int>(1, 2, 3), 4),
1212
equalTo(3),
1313
)
1414
}
1515

1616
@Test
1717
fun minimumTime2() {
1818
assertThat(
19-
Solution().minimumTime(mutableListOf<Int?>(1, 2, 3), mutableListOf<Int?>(3, 3, 3), 4),
19+
Solution().minimumTime(mutableListOf<Int>(1, 2, 3), mutableListOf<Int>(3, 3, 3), 4),
2020
equalTo(-1),
2121
)
2222
}

src/test/kotlin/g2801_2900/s2818_apply_operations_to_maximize_score/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ internal class SolutionTest {
88
@Test
99
fun maximumScore() {
1010
assertThat(
11-
Solution().maximumScore(mutableListOf<Int?>(8, 3, 9, 3, 8), 2),
11+
Solution().maximumScore(mutableListOf<Int>(8, 3, 9, 3, 8), 2),
1212
equalTo(81),
1313
)
1414
}
1515

1616
@Test
1717
fun maximumScore2() {
1818
assertThat(
19-
Solution().maximumScore(mutableListOf<Int?>(19, 12, 14, 6, 10, 18), 3),
19+
Solution().maximumScore(mutableListOf<Int>(19, 12, 14, 6, 10, 18), 3),
2020
equalTo(4788),
2121
)
2222
}

src/test/kotlin/g2901_3000/s2966_divide_array_into_arrays_with_max_difference/SolutionTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal class SolutionTest {
99
fun divideArray() {
1010
assertThat(
1111
Solution().divideArray(intArrayOf(1, 3, 4, 8, 7, 9, 3, 5, 1), 2),
12-
equalTo(arrayOf<IntArray?>(intArrayOf(1, 1, 3), intArrayOf(3, 4, 5), intArrayOf(7, 8, 9))),
12+
equalTo(arrayOf<IntArray>(intArrayOf(1, 1, 3), intArrayOf(3, 4, 5), intArrayOf(7, 8, 9))),
1313
)
1414
}
1515

src/test/kotlin/g3001_3100/s3076_shortest_uncommon_substring_in_an_array/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ internal class SolutionTest {
99
fun shortestSubstrings() {
1010
assertThat(
1111
Solution().shortestSubstrings(arrayOf("cab", "ad", "bad", "c")),
12-
equalTo(arrayOf<String?>("ab", "", "ba", "")),
12+
equalTo(arrayOf<String>("ab", "", "ba", "")),
1313
)
1414
}
1515

1616
@Test
1717
fun shortestSubstrings2() {
1818
assertThat(
1919
Solution().shortestSubstrings(arrayOf("abc", "bcd", "abcd")),
20-
equalTo(arrayOf<String?>("", "", "abcd")),
20+
equalTo(arrayOf<String>("", "", "abcd")),
2121
)
2222
}
2323
}

src/test/kotlin/g3201_3300/s3280_convert_date_to_binary/SolutionTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import org.junit.jupiter.api.Test
77
internal class SolutionTest {
88
@Test
99
fun convertDateToBinary() {
10-
assertThat<String?>(
10+
assertThat<String>(
1111
Solution().convertDateToBinary("2080-02-29"),
12-
equalTo<String?>("100000100000-10-11101"),
12+
equalTo<String>("100000100000-10-11101"),
1313
)
1414
}
1515

1616
@Test
1717
fun convertDateToBinary2() {
18-
assertThat<String?>(
18+
assertThat<String>(
1919
Solution().convertDateToBinary("1900-01-01"),
20-
equalTo<String?>("11101101100-1-1"),
20+
equalTo<String>("11101101100-1-1"),
2121
)
2222
}
2323
}

src/test/kotlin/g3201_3300/s3281_maximize_score_of_numbers_in_ranges/SolutionTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import org.junit.jupiter.api.Test
77
internal class SolutionTest {
88
@Test
99
fun maxPossibleScore() {
10-
assertThat<Int?>(
10+
assertThat<Int>(
1111
Solution().maxPossibleScore(intArrayOf(6, 0, 3), 2),
12-
equalTo<Int?>(4),
12+
equalTo<Int>(4),
1313
)
1414
}
1515

1616
@Test
1717
fun maxPossibleScore2() {
18-
assertThat<Int?>(
18+
assertThat<Int>(
1919
Solution().maxPossibleScore(intArrayOf(2, 6, 13, 13), 5),
20-
equalTo<Int?>(5),
20+
equalTo<Int>(5),
2121
)
2222
}
2323
}

src/test/kotlin/g3201_3300/s3282_reach_end_of_array_with_max_score/SolutionTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import org.junit.jupiter.api.Test
77
internal class SolutionTest {
88
@Test
99
fun findMaximumScore() {
10-
assertThat<Long?>(
10+
assertThat<Long>(
1111
Solution().findMaximumScore(mutableListOf<Int>(1, 3, 1, 5)),
12-
equalTo<Long?>(7L),
12+
equalTo<Long>(7L),
1313
)
1414
}
1515

1616
@Test
1717
fun findMaximumScore2() {
18-
assertThat<Long?>(
18+
assertThat<Long>(
1919
Solution().findMaximumScore(mutableListOf<Int>(4, 3, 1, 3, 2)),
20-
equalTo<Long?>(16L),
20+
equalTo<Long>(16L),
2121
)
2222
}
2323
}

src/test/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns/SolutionTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@ import org.junit.jupiter.api.Test
77
internal class SolutionTest {
88
@Test
99
fun maxMoves() {
10-
assertThat<Int?>(
10+
assertThat<Int>(
1111
Solution().maxMoves(1, 1, arrayOf(intArrayOf(0, 0))),
12-
equalTo<Int?>(4),
12+
equalTo<Int>(4),
1313
)
1414
}
1515

1616
@Test
1717
fun maxMoves2() {
18-
assertThat<Int?>(
18+
assertThat<Int>(
1919
Solution().maxMoves(
2020
0,
2121
2,
2222
arrayOf(intArrayOf(1, 1), intArrayOf(2, 2), intArrayOf(3, 3)),
2323
),
24-
equalTo<Int?>(8),
24+
equalTo<Int>(8),
2525
)
2626
}
2727

2828
@Test
2929
fun maxMoves3() {
30-
assertThat<Int?>(
30+
assertThat<Int>(
3131
Solution().maxMoves(
3232
0,
3333
0,
3434
arrayOf(intArrayOf(1, 2), intArrayOf(2, 4)),
3535
),
36-
equalTo<Int?>(3),
36+
equalTo<Int>(3),
3737
)
3838
}
3939
}

src/test/kotlin/g3201_3300/s3286_find_a_safe_walk_through_a_grid/SolutionTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package g3201_3300.s3286_find_a_safe_walk_through_a_grid
22

33
import com_github_leetcode.ArrayUtils.getLists
4-
import org.hamcrest.CoreMatchers
5-
import org.hamcrest.MatcherAssert
4+
import org.hamcrest.CoreMatchers.equalTo
5+
import org.hamcrest.MatcherAssert.assertThat
66
import org.junit.jupiter.api.Test
77

88
internal class SolutionTest {
99
@Test
1010
fun findSafeWalk() {
11-
MatcherAssert.assertThat<Boolean?>(
11+
assertThat<Boolean>(
1212
Solution()
1313
.findSafeWalk(
1414
getLists(
@@ -20,13 +20,13 @@ internal class SolutionTest {
2020
),
2121
1,
2222
),
23-
CoreMatchers.equalTo<Boolean?>(true),
23+
equalTo<Boolean>(true),
2424
)
2525
}
2626

2727
@Test
2828
fun findSafeWalk2() {
29-
MatcherAssert.assertThat<Boolean?>(
29+
assertThat<Boolean>(
3030
Solution()
3131
.findSafeWalk(
3232
getLists(
@@ -39,13 +39,13 @@ internal class SolutionTest {
3939
),
4040
3,
4141
),
42-
CoreMatchers.equalTo<Boolean?>(false),
42+
equalTo<Boolean>(false),
4343
)
4444
}
4545

4646
@Test
4747
fun findSafeWalk3() {
48-
MatcherAssert.assertThat<Boolean?>(
48+
assertThat<Boolean>(
4949
Solution()
5050
.findSafeWalk(
5151
getLists(
@@ -57,7 +57,7 @@ internal class SolutionTest {
5757
),
5858
5,
5959
),
60-
CoreMatchers.equalTo<Boolean?>(true),
60+
equalTo<Boolean>(true),
6161
)
6262
}
6363
}

0 commit comments

Comments
 (0)