A graph can be represented as adjacency matrix or adjacency list.
For a undirected graph {a,b} implies path from a to b and b to a. For directed graph {a,b} implies only path from a to b.
public Map> buildGraph(int[][] edges) {
A graph can be represented as adjacency matrix or adjacency list.
For a undirected graph {a,b} implies path from a to b and b to a. For directed graph {a,b} implies only path from a to b.
public Map> buildGraph(int[][] edges) {
#!/bin/bash | |
CASKS=( | |
adoptopenjdk | |
alfred | |
brave-browser | |
calibre | |
evernote | |
firefox | |
geekbench |
# Setup on Mac | |
// Place your settings in this file to overwrite the default settings | |
{ | |
"editor.fontSize": 16, | |
"window.zoomLevel": 0, | |
"workbench.colorTheme": "Visual Studio Dark", | |
"editor.renderWhitespace": "all", | |
"java.errors.incompleteClasspath.severity": "ignore", | |
"prettier.printWidth": 120, | |
"prettier.tabWidth": 4, | |
"telemetry.enableTelemetry": false, |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" | |
crossorigin="anonymous"> | |
<style> |
{ | |
"shell_cmd": "g++ -std=c++11 \"${file}\" -o \"${file_path}/${file_base_name}\"", | |
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", | |
"working_dir": "${file_path}", | |
"selector": "source.c, source.c++", | |
"variants": | |
[ | |
{ | |
"name": "Run", |
#!/bin/bash | |
# -------------------------------- | |
# Totally Simple Web Server (TSWS) | |
# -------------------------------- | |
# | |
# (c) 2015 Dave Fletcher | |
# All Rights Reserved | |
# | |
# This is free and unencumbered software released into the public domain. |
#include <iostream> | |
#include <algorithm> | |
/* | |
Input: "Hello how are you" | |
Output: "olleH woh era uoy" | |
*/ | |
using namespace std; | |
void printReverse(string str){ |
void MaxRootToLeafSum(node *root, int & maxSum, int currentSum){ | |
if ( !root ) | |
return; | |
if ( root->data + currentSum > maxSum ) | |
maxSum = root->data + currentSum ; | |
currentSum += root->data; |
#include <iostream> | |
#include <malloc.h> | |
#include <stack> | |
#include <queue> | |
using namespace std; | |
typedef struct node { | |
int data; | |
struct node* left; |