Skip to content

Instantly share code, notes, and snippets.

@leosabbir
leosabbir / Enemies.java
Created July 25, 2019 00:03
Daily Coding Problem #292
/* File: Enemies.java
* Created: 7/24/2019
* Author: Sabbir Manandhar
*
* Copyright (c) 2019 Hogwart Inc.
*/
import java.util.*;
//=======================================================================================
@leosabbir
leosabbir / MinimumRange.java
Created July 8, 2019 19:18
Program to find the minimum range of set that includes at least one element from each of the k sorted lists
/**
* @author Sabbir Manandhar
* ManandharSabbir@gmail.com
*/
class MinimumRange {
public int[] smallestRange(List<List<Integer>> nums) {
// Min heap to store intermediate k elements
PriorityQueue<int[]> heap = new PriorityQueue<>(new Comparator<int[]>() {
public int compare(int[] a, int[] b) {
return a[0] - b[0];
package authorization
import (
"testing"
"github.com/stretchr/testify/assert"
)
// executes becore init() method so that fileReader can be injected
var _ = func() (_ struct{}) {
package authorization
import (
"encoding/json"
"io/ioutil"
"log"
"path/filepath"
)
//---------------------------------------------------------------------------------------
@leosabbir
leosabbir / Solution.java
Created June 17, 2019 15:28
Daily Coding Problem #332
import java.io.*;
import java.util.Scanner;
class Solution {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
long X = sc.nextLong();
long S = sc.nextLong();
@leosabbir
leosabbir / MockStaticMethodTest.java
Last active May 17, 2019 17:57
class to test mocking of private and public static method
/* File: MockStaticMethodTest.java
* Created: 5/17/2019
* Author: Sabbir Manandhar
*
* Copyright (c) 2019 Hogwart Inc.
*/
package com.hogwart;
import org.junit.Assert;
@leosabbir
leosabbir / ShortestPath294.java
Created May 9, 2019 16:33
daily coding problem 294 alternative solution using memoization
/* File: ShortestPath294.java
* Created: 2019-05-08
* Author: Sabbir Manandhar
*
* Copyright (c) 2019 Hogwart Inc.
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
/* File: ShortestPath294.java
* Created: 2019-05-08
* Author: Sabbir Manandhar
*
* Copyright (c) 2019 Hogwart Inc.
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@leosabbir
leosabbir / shortest_path.go
Last active May 8, 2019 22:00
GoLang solution for Daily Coding Problem #294
package main
import "fmt"
// TestShortestPath solves sample examples
func TestShortestPath() {
elevations := map[int]int{
0: 5,
1: 25,
2: 15,
@leosabbir
leosabbir / Graph.java
Created May 4, 2019 00:06
DFS, Cycle Detection and Topological sorting of a graph
/* File: GraphTraversals.java
* Created: 5/3/2019
* Author: Sabbir Manandhar
*
* Copyright (c) 2019 Hogwart Inc.
*/
//=======================================================================================
import java.util.ArrayList;