This file contains hidden or 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
// O(m+n) | |
var foo = function(arrA, arrB) { | |
var iB, | |
iA; | |
for (iA = iB = 0; iB < arrB.length; iB += 1) { | |
while (arrB[iB] > arrA[iA] && iA < arrA.length) { | |
iA += 1; | |
} |
This file contains hidden or 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> | |
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>Test by Jesse</title> | |
</head> | |
<body> | |
<nav id = 'sidenav'> | |
<ul> |
This file contains hidden or 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 getDescendants(node, n) { | |
var res = []; | |
function f(children, lev) { | |
if (lev >= n) { | |
res = res.concat(Array.prototype.slice.apply(children)); | |
return; |
This file contains hidden or 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 arr = [], | |
i; | |
for (i = 0; i < 10000; i++) { | |
arr[i] = Math.floor(Math.random()*9999); | |
} | |
// console.log(arr); | |
function findLG(arr) { |
This file contains hidden or 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 arr = []; | |
for (var i=0; i< 10000; i++) { | |
arr[i] = Math.floor(Math.random()*9997+1); //1~9998 | |
} | |
// console.log(a); | |
function sort(arr) { | |
This file contains hidden or 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
window.myApp = (function (myApp) { | |
// O(m+n) | |
myApp.containChar = function (Str1, Str2) { | |
if (typeof Str1 !== "string" || typeof Str2 !== "string") { | |
return; | |
} | |
var longStr, |
This file contains hidden or 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
window.myApp = (function (myApp) { | |
/* | |
* 123456 --leftShift+2--> 345612 | |
* 1. 12 | 3456 | |
* 2. 21 | 3456 | |
* 3. 21 | 6543 | |
* 4. 216543 | |
* 5. 345621 | |
*/ | |
myApp.leftShift = function (arr, offset) { |
This file contains hidden or 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
String.prototype.slice(start[,end]); If a negative number is given, it is treated as strLength + start/end. | |
String.prototype.substr(start[,length]); If a negative number is given to start, it is treated as strLength + start. | |
String.prototype.substring(indexA[,indexB]); If either argument is less than 0 or is NaN, it is treated as if it were 0. | |
If either argument is greater than stringName.length, it is treated as if it were stringName.length. | |
var s1 = "0123456789" | |
console.log(s1.slice(3, 7)); //"3456" |
This file contains hidden or 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
void swap(char *a, char *b) { | |
*a = *a^*b; | |
*b = *a^*b; | |
*a = *a^*b; | |
} | |
void reverse(char *a) { | |
if(!a) return; | |
int i, n = -1; | |
while(a[++n]); |
This file contains hidden or 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
package com.crimx.adapter; | |
public class Adapter implements Plug2{ | |
private Plug1 plug1; | |
public Adapter(Plug1 p1) { | |
Plug1 = p1; | |
} | |
public void slot1() { |