Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Sudip Purkayastha sudipp

🎯
Focusing
Block or report user

Report or block sudipp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View leetcode 117
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 )
{
View Leetcode968
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
{
View Leetcode685
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
@sudipp
sudipp / usb-drive-util-test.js
Created Jan 15, 2019
usb-drive-util-test.js
View usb-drive-util-test.js
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;
}
View mediaController.js
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"});
}
View uriTokenizer.js
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){
You can’t perform that action at this time.