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
mergesort [] = error "Empty list" | |
mergesort [x] = [x] | |
mergesort xs = | |
merge (mergesort left) (mergesort right) | |
where | |
(left,right) = splitAt (length xs `div` 2) xs | |
merge [] ys = ys | |
merge xs [] = xs | |
merge xs@(x:xs') ys@(y:ys') | |
| x<=y = x: merge xs' ys |
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
1 2 3 4 5 |
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
int uf[SIZE]; | |
void init() { | |
std::iota(uf, uf+SIZE, 0); | |
} | |
int root(int x) { | |
int _x = x; | |
while(x!=uf[x]) x = uf[x] /* = uf[uf[x]] */ ; | |
return uf[_x] = x; |
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
{ | |
"manifest_version": 2, | |
"name": "Tab url", | |
"description": "Shows url of the current page", | |
"version": "1.0", | |
"browser_action": { | |
"default_icon": "icon.png", | |
"default_popup": "popup.html" |
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
def lps(i, j) | |
return $dp[i][j] if $dp[i][j] | |
return 1 if i==j | |
return 0 if i>j | |
if $a[i] == $a[j] | |
z = lps(i+1, j-1) + 2 | |
else | |
z = [ lps(i+1, j), lps(i, j-1) ].max | |
end | |
$dp[i][j] = z |
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
package main | |
import ( | |
"fmt" | |
) | |
func ints(n int) ([]int) { | |
xs := make([]int, n) | |
for i := range xs { | |
fmt.Scan(&xs[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
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int find_substring(string str, string pattern) { | |
// Step 0. Should not be empty string | |
if( str.size() == 0 || pattern.size() == 0) | |
return -1; |
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
?- sudoku44(A1,2,3,A4,B1,B2,B3,2,1,C2,C3,C4,D1,4,1,D4). | |
1 2 3 4 | |
------------- | |
A | . 2 | 3 . | | |
B | . . | . 2 | | |
------------- | |
C | 1 . | . . | | |
D | . 4 | 1 . | | |
------------- |
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
data BinarySearchTree = Null | Node Int (BinarySearchTree) (BinarySearchTree) | |
deriving Show | |
insert Null val = Node val Null Null | |
insert (Node x left right) val | |
| x > val = Node x left' right | |
| otherwise = Node x left right' | |
where | |
left' = insert left val | |
right' = insert right val |
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
version: "2" | |
services: | |
gate: | |
image: nginx:latest | |
ports: | |
- 80:80 | |
volumes: | |
- ./load-balance.conf:/etc/nginx/conf.d/default.conf | |
web1: |
OlderNewer