File tree Expand file tree Collapse file tree
find-minimum-in-rotated-sorted-array
maximum-depth-of-binary-tree Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,9 +12,13 @@ function findMin(nums) {
1212 let left = 0 ;
1313 let right = nums . length - 1 ;
1414
15+ if ( nums [ left ] <= nums [ right ] ) return nums [ left ] ; // 일자 배열인 경우
16+
1517 while ( left < right ) {
1618 let mid = Math . floor ( ( left + right ) / 2 ) ;
1719
20+ if ( nums [ mid ] > nums [ mid + 1 ] ) return nums [ mid + 1 ] ; // mid의 바로 옆에서 초기화되는 경우
21+
1822 if ( nums [ mid ] > nums [ right ] ) {
1923 left = mid + 1 ;
2024 } else {
Original file line number Diff line number Diff line change @@ -21,7 +21,5 @@ function maxDepth(root) {
2121 let left_depth = maxDepth ( root . left ) ;
2222 let right_depth = maxDepth ( root . right ) ;
2323
24- let count = Math . max ( left_depth , right_depth ) + 1 ;
25-
26- return count ;
24+ return Math . max ( left_depth , right_depth ) + 1 ;
2725}
You can’t perform that action at this time.
0 commit comments