Given a binary tree, return the sum of values of its deepest leaves.
Find the largest depth first, then sum up each node at the largest depth
public int findMax(int n, int[] arr) { | |
// let freqMap be a map where the keys are the elements in arr | |
// and the values are its frequency or the number of occurences in arr | |
List<Integer> list = new ArrayList<>(); | |
for (int i = 1; i <= n; i++) { | |
if (!freqMap.contains(i)) continue; | |
for (int count = 0; count < freqMap.get(i); count++) { | |
list.add(i); |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Tree Example</title> | |
<style> | |
.node { | |
cursor: pointer; | |
} | |
.node circle { |
#!/bin/bash | |
#PBS -l walltime=24:00:00 | |
#PBS -l procs=4 | |
#PBS -q normal_q | |
#PBS -A cs4884s18 | |
#PBS -W group_list=newriver | |
# Purge existing modules. | |
module purge |
# Output for running the command: | |
# > kallisto quant -i test/testset-kallisto-index.idx -o test-output --pseudobam test/reads_1.fq test/reads_2.fq | samtools view -bS - | samtools view -h -F 0x04 -b - | samtools sort - -o test-output/FastViromeExplorer-reads-mapped-sorted.sam > foo | |
[quant] fragment length distribution will be estimated from the data | |
[index] k-mer length: 31 | |
[index] number of targets: 97 | |
[index] number of k-mers: 515,417 | |
[index] number of equivalence classes: 101 | |
[quant] running in paired-end mode | |
[quant] will process pair 1: test/reads_1.fq |
var express = require('express'); | |
var mongojs = require('mongojs'); | |
var db = mongojs(process.env.MONGO_URL || 'mongodb://localhost:27017/local'); | |
var app = express(); | |
app.use('/public', express.static('public')) | |
app.listen(3000, () => console.log('listening on *:3000')); | |
#!/bin/bash | |
echo "Compiling source code" | |
javac SSAD.java | |
echo "Running test" | |
for i in `seq 1 1 $1`; do | |
java -jar SSADGen.jar Graph${i}.txt profResults${i}.txt | |
java SSAD Graph${i}.txt log${i}.txt |
#!/bin/bash | |
echo "Compiling source code" | |
javac ../src/Minor/P2/DS/BST.java | |
mv ../src/Minor/P2/DS/*.class Minor/P2/DS | |
java -jar BSTGenerator.jar | |
echo "Running test" | |
java testDriver |
import java.util.Scanner; | |
public class KMP { | |
public static void main(String[] args) { | |
Scanner kb = new Scanner(System.in); | |
String search = kb.next(); | |
String target = kb.next(); | |
int result = KMP(search, target); | |
if (result == -1) { | |
System.out.println("NO"); |
socket.on('connection', () => { | |
var messages = db.collection('messages').find({ | |
chatId: chatId // We want all the messages for that room. | |
}).sort({ | |
createdAt: -1 // It's best not to assume that it is in order. | |
}); | |
socket.emit('message', messages); | |
}); |