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
wordsOfLength :: [Char] -> Integer -> [[Char]] | |
wordsOfLength alphabet n | n <= 0 = [""] | |
| otherwise = [a:b | a <- alphabet, b <- wordsOfLength alphabet (n-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
{-WETT-} | |
perms :: [Char] -> [[Char]] | |
perms [] = [""] | |
perms xs = reverse $ sort $ nub [x:y | x <- xs, y <- perms $ delete x xs] | |
{-TTEW-} |
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
static class Node | |
{ | |
int val; | |
Node left; | |
Node right; | |
Node(int val, Node left, Node right) | |
{ | |
this.val = val; | |
this.left = left; |
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 benchmark; | |
import org.openjdk.jmh.annotations.GenerateMicroBenchmark; | |
import java.util.concurrent.atomic.AtomicInteger; | |
public class NextEventLoopBenchmark { | |
@GenerateMicroBenchmark | |
public void newNext8 () { |
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
Benchmark Mode Thr Count Sec Mean Mean error Units | |
b.NextEventLoopBenchmark.newNext16 thrpt 1 200 1 8.562 0.006 ops/ms | |
b.NextEventLoopBenchmark.newNext19 thrpt 1 200 1 8.500 0.005 ops/ms | |
b.NextEventLoopBenchmark.newNext8 thrpt 1 200 1 8.567 0.007 ops/ms | |
b.NextEventLoopBenchmark.newNext9 thrpt 1 200 1 8.434 0.007 ops/ms | |
b.NextEventLoopBenchmark.existingNext16 thrpt 1 200 1 8.485 0.005 ops/ms | |
b.NextEventLoopBenchmark.existingNext19 thrpt 1 200 1 8.506 0.003 ops/ms |
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
Benchmark Mode Thr Count Sec Mean Mean error Units | |
b.NextEventLoopBenchmark.existingNext16 thrpt 1 100 1 0.387 0.001 ops/ms | |
b.NextEventLoopBenchmark.existingNext19 thrpt 1 100 1 0.386 0.002 ops/ms | |
b.NextEventLoopBenchmark.newNext16 thrpt 1 100 1 0.828 0.003 ops/ms | |
b.NextEventLoopBenchmark.newNext8 thrpt 1 100 1 0.828 0.003 ops/ms | |
b.NextEventLoopBenchmark.newNext19 thrpt 1 100 1 0.371 0.002 ops/ms | |
b.NextEventLoopBenchmark.newNext9 thrpt 1 100 1 0.371 0.002 ops/ms |
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
import java.util.Arrays; | |
import java.util.Scanner; | |
public class Solution { | |
private static int discoverSink(int[][] farmland, int[][] basins, int nextbasin, int i, int j) { | |
if (basins[i][j] != 0) { | |
return basins[i][j]; | |
// perform a dfs starting at i,j searching for a sink | |
} else { | |
int minaltitude = farmland[i][j]; |
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 palantir; | |
import java.util.Comparator; | |
public class FileNameComparator implements Comparator<String> | |
{ | |
/* | |
* DESCRIPTION: | |
* Numbers in the string are compared by their natural order | |
* and not their ASCII order. (2 < 10) |
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
// Welcome back! I just wrote down this code from the top of my head to express the main ideas. | |
// I didn't compile or run it. It's mostly pseudocode anyway. | |
// The problem of associating tasks to channels could be solved by | |
// having the developer tell us, which channel a task belongs to | |
// this would make filtering the tasks on migration very easy. | |
// The downside is that it is subject to user errors. | |
// | |
// null if it doesn't belong to any particular channel |
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
// Hi there! I just want to let you know that I have neither compiled nor run | |
// this code. | |
EventLoopGroup workerGroup = new NioEventLoopGroup(32, new CustomEventExecutorChooser()); | |
public interface EventExecutorChooser { | |
void addExecutor(EventExecutor executor) | |
MetricsProvider newMetricsProvider(); | |
EventExecutor next(); | |
} |
OlderNewer