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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="JavaScript Bubble Sort Algorithm"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<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
" Use Vim settings, rather then Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
" ================ General Config ==================== | |
set number "Line numbers are good | |
set backspace=indent,eol,start "Allow backspace in insert mode | |
set history=1000 "Store lots of :cmdline history | |
set showcmd "Show incomplete cmds down the bottom |
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
function missingNumbers(nums) { | |
var missedNums = []; | |
var sortedArr = nums.sort(function(a, b) { | |
return a - b; | |
}); | |
sortedArr.forEach(function(ele, i, arr) { | |
var a = +arr[i], | |
b = +arr[i + 1]; | |
if (!b) return; | |
if (isNaN(b)) { |
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
var dupEleArr = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 20, 3, 3, 3, 32, 324, 5, 52]; | |
/* | |
Sort the given array and filter the array by checking | |
If two adjucent elements are equal and then the next immediate | |
element should not be equal... | |
Note: Tested with array of numbers, Not tested with strings | |
*/ | |
var dupEle = dupEleArr.sort().filter(function(ele,i,arr){ | |
return arr.length > 3 ? (arr[i] == arr[i+1] && arr[i+1] != arr[i+2]) : (arr.length == 2) ? (arr[i] == arr[i+1]) : true; |