Skip to content

Commit 1fc7ed6

Browse files
authored
Updated tags, fixed compile warnings.
1 parent e1bf131 commit 1fc7ed6

File tree

21 files changed

+138
-35
lines changed

21 files changed

+138
-35
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package g0001_0100.s0050_powx_n
22

33
// #Medium #Top_Interview_Questions #Math #Recursion #Udemy_Integers
4-
// #2022_09_21_Time_307_ms_(17.33%)_Space_35.2_MB_(54.67%)
4+
// #2022_09_27_Time_264_ms_(52.98%)_Space_34.9_MB_(76.82%)
55

6+
@Suppress("NAME_SHADOWING")
67
class Solution {
78
fun myPow(x: Double, n: Int): Double {
89
var x = x

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package g0001_0100.s0059_spiral_matrix_ii
22

33
// #Medium #Array #Matrix #Simulation #Data_Structure_II_Day_3_Array
4-
// #2022_09_22_Time_292_ms_(18.33%)_Space_34.7_MB_(71.67%)
4+
// #2022_09_27_Time_153_ms_(100.00%)_Space_34_MB_(98.15%)
55

66
class Solution {
77
fun generateMatrix(n: Int): Array<IntArray> {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package g0001_0100.s0060_permutation_sequence
22

33
// #Hard #Math #Recursion #2022_09_22_Time_293_ms_(27.78%)_Space_34.2_MB_(61.11%)
44

5+
@Suppress("NAME_SHADOWING")
56
class Solution {
67
fun getPermutation(n: Int, k: Int): String {
78
var k = k

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com_github_leetcode.ListNode
1313
* var next: ListNode? = null
1414
* }
1515
*/
16+
@Suppress("NAME_SHADOWING")
1617
class Solution {
1718
fun partition(head: ListNode?, x: Int): ListNode? {
1819
var head = head
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package g0001_0100.s0089_gray_code
22

33
// #Medium #Math #Bit_Manipulation #Backtracking
4-
// #2022_09_26_Time_528_ms_(62.86%)_Space_61.8_MB_(88.57%)
5-
6-
import java.util.Arrays
4+
// #2022_09_27_Time_273_ms_(100.00%)_Space_44.1_MB_(97.14%)
75

6+
@Suppress("NAME_SHADOWING")
87
class Solution {
9-
fun grayCode(n: Int): List<Int> {
8+
fun grayCode(n: Int): List<Int?> {
109
var n = n
1110
var n1 = arrayOf<Int?>(0)
1211
var shift = 1
@@ -16,13 +15,13 @@ class Solution {
1615
for (integer in n1) {
1716
temp[pos++] = integer
1817
}
19-
for (i in 0..n1.size - 1) {
20-
temp[pos++] = n1[n1.size - i - 1]!! or shift
18+
for (i in n1.indices.reversed()) {
19+
temp[pos++] = n1[i]!! or shift
2120
}
2221
n1 = temp
2322
shift = shift shl 1
2423
n--
2524
}
26-
return Arrays.asList(*n1) as List<Int>
25+
return listOf(*n1)
2726
}
2827
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package g0001_0100.s0091_decode_ways
22

33
// #Medium #Top_Interview_Questions #String #Dynamic_Programming
44
// #Algorithm_II_Day_15_Dynamic_Programming #Dynamic_Programming_I_Day_10
5-
// #2022_09_26_Time_327_ms_(17.68%)_Space_34.7_MB_(82.93%)
5+
// #2022_09_27_Time_237_ms_(76.88%)_Space_34.5_MB_(86.88%)
66

77
class Solution {
88
fun numDecodings(s: String): Int {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com_github_leetcode.ListNode
1313
* var next: ListNode? = null
1414
* }
1515
*/
16+
@Suppress("NAME_SHADOWING")
1617
class Solution {
1718
fun reverseBetween(head: ListNode?, left: Int, right: Int): ListNode? {
1819
var head = head

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@ package g0001_0100.s0094_binary_tree_inorder_traversal
22

33
// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Tree #Binary_Tree
44
// #Stack #Data_Structure_I_Day_10_Tree #Udemy_Tree_Stack_Queue
5-
// #2022_09_01_Time_283_ms_(17.97%)_Space_35.7_MB_(17.47%)
5+
// #2022_09_27_Time_269_ms_(38.80%)_Space_35.9_MB_(14.49%)
66

77
import com_github_leetcode.TreeNode
88

9+
/*
10+
* Example:
11+
* var ti = TreeNode(5)
12+
* var v = ti.`val`
13+
* Definition for a binary tree node.
14+
* class TreeNode(var `val`: Int) {
15+
* var left: TreeNode? = null
16+
* var right: TreeNode? = null
17+
* }
18+
*/
919
class Solution {
1020
fun inorderTraversal(root: TreeNode?): List<Int> {
1121
if (root == null) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Solution {
3939
}
4040

4141
private fun insert(dest: TreeNode?, n: TreeNode, from: TreeNode) {
42-
if (dest != null && dest.`val` === from.`val`) {
42+
if (dest != null && dest.`val` == from.`val`) {
4343
val h: TreeNode? = dest.right
4444
dest.right = n
4545
n.left = h
@@ -53,6 +53,6 @@ class Solution {
5353
private fun copy(n: TreeNode?): TreeNode? {
5454
return if (n == null) {
5555
null
56-
} else TreeNode(n.`val`, copy(n.left), copy(n.right))
56+
} else { TreeNode(n.`val`, copy(n.left), copy(n.right)) }
5757
}
5858
}

0 commit comments

Comments
 (0)