|
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
memo = new int[V][1 << V]; | |
T = new int[V][V]; // adjacency matrix | |
int min_dist_from_0 = DP_TSP(0, 1); | |
int DP_TSP(int u, int m) { // m is visited mask (bitmask) | |
if (m == ((1 << V) - 1)) // all 1, all vertices have been visited | |
return T[u][0]; // no choice, return to vertex 0 | |
if (memo[u][m] != -1) // computed before | |
return memo[u][m]; |
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
void dijkstra() { | |
int[] dist = new int[n + 1]; | |
boolean[] visited = new boolean[n + 1]; | |
for (int source = 0; source < k + 1; source++) { | |
arrays.fill(dist, INFINITY); | |
arrays.fill(visited, false); | |
dist[list[source]] = 0; | |
for (int t = 0; t < n; t++) { | |
int min = INFINITY; |
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
import java.util.*; | |
public class UniqueArray { | |
public static int[] unique(int[] integers) { | |
return Arrays.stream(integers).distinct().toArray(); | |
} | |
} |
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
test |
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 unfollow() { | |
window.scrollTo(0, document.body.scrollHeight); | |
setTimeout(function() { | |
console.log('unfollowed'); | |
let list = document.querySelectorAll('.follow-link.zg-unfollow.meta-item'); | |
list[0].click(); | |
unfollow() | |
}, 1000) | |
} | |
unfollow() |
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
{ | |
"title": "Emit Command+Backtick if Command and Escape are pressed", | |
"rules": [ | |
{ | |
"description": "Change escape to backtick if pressed with command", | |
"manipulators": [ | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "escape", |
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 makeReplacer(str) { | |
const regex = /\$\w+\.(\w+)/g; | |
let strFragments = []; // stores static strings, or a function to get value from map | |
let m; // regex match object | |
let idx; // index tracking the position of one match in `str` | |
while ((m = regex.exec(str)) !== null) { | |
// This is necessary to avoid infinite loops with zero-width matches | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} |
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
filename='yourfilename' | |
filetype='text/csv' | |
token='my oauth token' | |
url='http://localhost/upload' | |
curl "$url" \ | |
--form "data=@$filename;type=$filetype" \ | |
--form "name=somename" \ | |
-H "Authorization: Bearer $token" | |
OlderNewer