Skip to content

Instantly share code, notes, and snippets.

View Toomean's full-sized avatar

Artem Tumin Toomean

View GitHub Profile
/**
* Classic Binary Search (Model: "The Vise")
* * Time Complexity: O(log n)
* Space Complexity: O(1)
*/
export function binarySearch(nums: number[], target: number): number {
let left = 0;
let right = nums.length - 1;
while (left <= right) {
@Toomean
Toomean / binary-search.js
Created August 29, 2019 20:55
Javascript function that implements binary search algorithm
function binarySearch( array, item ) {
let low = 0;
let high = array.length - 1;
while ( low <= high ) {
let mid = Math.floor( ( low + high ) / 2 );
let guess = array[ mid ];
if ( guess > item ) {
high = mid - 1;
@Toomean
Toomean / css-visually-hidden.css
Created August 29, 2019 10:18
CSS: Visually hidden
.visually-hidden {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
padding:0 !important;
border:0 !important;
height: 1px !important;
width: 1px !important;
overflow: hidden;
}