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
public class Solution { | |
interface Operation {public int op(int a, int b);} | |
class Add implements Operation{public int op(int a, int b){return a+b;}} | |
class Sub implements Operation{public int op(int b, int a){return a-b;}} | |
class Mul implements Operation{public int op(int a, int b){return a*b;}} | |
class Div implements Operation{public int op(int b, int a){return a/b;}} | |
public Operation getOp(String t) { | |
switch(t){ | |
case "+": return new Add(); | |
case "-": return new Sub(); |
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
### Keybase proof | |
I hereby claim: | |
* I am chmllr on github. | |
* I am mllr (https://keybase.io/mllr) on keybase. | |
* I have a public key whose fingerprint is AB1C D595 F657 ED01 E94D 9B83 F1F6 360E EA40 67EF | |
To claim this, I am signing this object: |
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 combinationSum = function (candidates, target) { | |
candidates.sort(function (a, b) { return a - b }); | |
var C = {}; | |
var f = function (n) { | |
if (n in C) return C[n]; | |
var result = []; | |
if (n > 0) | |
candidates.forEach(function (cand) { | |
if (n == cand) result.push([cand]); | |
else f(n - cand).forEach(function (comb) { |
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 containsNearbyAlmostDuplicate = function (nums, k, t) { | |
if (k < 1 || t < 0 || nums.length < 2) return false; | |
var B = {}, MIN = -1 * 2147483648; | |
for (var i = 0; i < nums.length; ++i) { | |
var N = nums[i] - MIN; | |
var bucket = Math.floor(N / t); | |
var list = B[bucket] || []; | |
var cands = list.concat(B[bucket - 1] || [], B[bucket + 1] || []); | |
for (var i = 0; i < cands.length; ++i) { | |
var x = cands[i]; |
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 containsNearbyAlmostDuplicate = function (nums, k, t) { | |
if (k < 1 || t < 0 || nums.length < 2) return false; | |
var B = {}, MIN = -1 * 2147483648; | |
for (var i = 0; i < nums.length; ++i) { | |
var N = nums[i] - MIN; | |
var bucket = Math.floor(N / (t+1)); | |
if (bucket in B || | |
(bucket - 1) in B && Math.abs(B[bucket - 1] - N) <= t || | |
(bucket + 1) in B && Math.abs(B[bucket + 1] - N) <= t) | |
return true; |
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 numbers = readLine.split(" ").map(_.toInt).toList.sorted | |
numbers = numbers.distinct ++ (numbers diff numbers.distinct) | |
def solve(acc: Int, list: List[Int]):Int = list match{ | |
case (h::Nil) => acc | |
case (h::t) => if (h+1 == t.head) solve(acc,t) else solve(acc+1,h+1::t.slice(0,t.size-1)) | |
} | |
println(solve(0,numbers)) |
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 n = readline(); | |
var houses = readline().split(" "); | |
var max = -1, L = houses.length, result = new Array(n); | |
for (var i = L-1; i>=0; --i) { | |
var T = houses[i]; | |
result[i] = T > max ? 0 : max - T + 1; | |
max = Math.max(T, max); | |
} |
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
; for i > 2 | |
(defn prime? [i] | |
(not (some | |
#(= 0 (mod i %)) | |
(cons 2 (range 3 (inc (Math/sqrt i)) 2))))) |
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
<html> | |
<body> | |
<div id="box1">1</div> | |
<div id="box2">2</div> | |
<div id="box3">3</div> | |
<div id="box4">4</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" | |
type="text/javascript"></script> | |
<script> | |
for (var i = 1; i < 5; i++) { |
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
(defn wlk | |
[nodelist [tag attrs & nodes]] | |
(if (= (:class attrs) "r") | |
(conj nodelist (:href (second (first nodes)))) | |
(reduce wlk nodelist (filter coll? nodes)))) |
OlderNewer