This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Binary search is a search algorithm that finds the position of a target value within a sorted array. | |
* Binary search has O(log n) complexity. | |
* @param {!Array} list The sorted array. | |
* @param {*} item The item to search. | |
* @return {number} Returns the index of the item in the array. | |
* @see https://en.wikipedia.org/wiki/Binary_search_algorithm | |
*/ | |
const binarySearch = (list, item) => { | |
let low = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family: arial, sans-serif; | |
-webkit-font-smoothing: antialiased; | |
} | |
#main { | |
margin: 5em auto 0; | |
} | |
header, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: White; | |
color: DarkSlateGray; | |
} | |
header, | |
footer { | |
background-color: Indigo; | |
color: White; | |
} | |
#main > aside { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aside, footer, header, #main > article { | |
padding: 1em; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<header>Header</header> | |
<div id="main"> | |
<article>Content</article> | |
<aside>Left sidebar</aside> | |
<aside>Right sidebar</aside> | |
</div> | |
<footer>Footer</footer> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
box-sizing: border-box; | |
margin: 0; | |
padding: 0; | |
} | |
body { | |
display: flex; | |
flex-direction: column; | |
min-height: 100vh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Merge two sorted integer arrays nums1 and nums2 into nums1, sorted in non-decreasing order. | |
* The time complexity of this function is O(m + n), | |
* @param {number[]} nums1 The first sorted array containing elements to be merged. | |
* @param {number} m The number of elements in nums1 (excluding additional space for merging). | |
* @param {number[]} nums2 The second sorted array containing elements to be merged into nums1. | |
* @param {number} n The number of elements in nums2. | |
* @see https://leetcode.com/problems/merge-sorted-array/ | |
*/ | |
var merge = function(nums1, m, nums2, n) { |
NewerOlder