Skip to content

Instantly share code, notes, and snippets.

View maximpn's full-sized avatar

Maxim Palenov maximpn

  • Amsterdam Area, The Netherlands
View GitHub Profile
class Solution {
int[] ans, count;
List<Set<Integer>> graph;
int N;
public int[] sumOfDistancesInTree(int N, int[][] edges) {
this.N = N;
graph = new ArrayList<Set<Integer>>();
ans = new int[N];
count = new int[N];
Arrays.fill(count, 1);
@maximpn
maximpn / buterbroad.svg
Last active June 4, 2018 08:03
Page with a menu
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maximpn
maximpn / angular2-stat.js
Last active April 27, 2017 15:00
Get statistic about total count of ts files and files which is implemented by using Angular 2
const fs = require("fs");
const path = require("path");
const walk = require("walk");
const PROJECT_PATH = path.resolve(path.dirname(__dirname), 'src'),
checkRegExp = new RegExp("(^\\@[^@\\(]+\\()", "m"),
filesCountToSkip = 0; // Some magic number of files which aren't related to the Angular at all
let totalTSFiles = 0,
angular2TSFiles = 0;
/**
* ES6 implementation of flatten function.
* It's sorter due to syntax sugar but usually consume more memory due to larger amount of function calls.
*/
function flatten(arr) {
return arr.reduce(
(a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []
);
}