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
public Node Connect(Node root) { | |
Node rootPointer = root; | |
//maintain 2 pointers | |
Node childHead = null; //NEXT level's head pointer | |
Node child = null; //NEXT level's traversal pointer | |
while (root !=null ) | |
{ |
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
private static int CoverLogic(TreeNode node, Stack<TreeNode> stack, HashSet<TreeNode> covered, int minCamera) | |
{ | |
//if node has any uncovered child, then cover it and it's parent(if any) | |
if ((node.left != null && !covered.Contains(node.left)) || (node.right != null && !covered.Contains(node.right))) | |
{ | |
minCamera++; | |
covered.Add(node); | |
if (stack.Any()) //has parent | |
{ |
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
public class Solution { | |
public int[] FindRedundantDirectedConnection(int[][] edges) | |
{ | |
/* | |
Step 1. Build In and Out Degree map, detect if any any vertex with Multiple parents. | |
Step 2. If we don't find vertex 'A' with multiple parents | |
2.1) Start at 'root' and detect any cycle with DFS, return the edge causing the cycle | |
Step 3. If we find vertex 'A' with multiple parents | |
3.1) if out degree at vertex 'A' is > 0, i.e there is a edge going out of the 'A' vertex | |
3.1.1) Start at 'A' and detect any cycle with DFS, return the edge causing the cycle |
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
const drives = require('../src/drives').Drives; | |
function loadUSBDrvList(){ | |
drives.loadUSBDriveDetails().then(function(result){ | |
if(result && result.length== 0){ | |
console.log('No USB drive found in the system'); | |
return; | |
} |
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
let _ = require('lodash'); | |
const uriTokenizer = require('../utils/uriTokenizer'); | |
const tokenizer = new uriTokenizer( { algorithm: 'RS256', expiresIn : '15m' }, { algorithms: ['RS256'] }); | |
const media = require('../Model/Media'); | |
async function buildMediaFileDownloadUrl(req, mediafile){ | |
let uri= req.protocol + '://' + req.get('host') + '/file/' + (mediafile || "").replace(/^\//, ''); | |
return await tokenizer.signUri(uri, { divison : "Honda"}); | |
} |
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
const fs = require('fs'); | |
const config = require('../assets/configs/config'); | |
const jwt = require('jsonwebtoken'); | |
const urlBuilder = require('build-url'); | |
//We use Public/Private key, but you can use Secret (with HMAC algorithm) | |
let secretOrPrivateKey = fs.readFileSync(config.sslPrivatekey_path); | |
let secretOrPublicKey = fs.readFileSync(config.sslPublickey_path); | |
function uriTokenizer(signOptions, verifyOptions){ |