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
Run following commands in sequence: | |
docker network create notification-setting-mongo-network | |
docker run -d --network notification-setting-mongo-network --name notification-setting-mongo \ | |
-e MONGO_INITDB_ROOT_USERNAME=admin \ | |
-e MONGO_INITDB_ROOT_PASSWORD=abc1234 \ | |
mongo:latest | |
docker run -it --rm --network notification-setting-mongo-network mongo \ |
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
// A solution for walls and gates problem on leetcode in golang | |
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
const EMPTY int = math.MaxInt32 | |
const GATE int = 0 |
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
/** | |
* Return the length of the shortest path between root and target node. | |
*/ | |
int BFS(Node root, Node target) { | |
Queue<Node> queue; // store all nodes which are waiting to be processed | |
Set<Node> visited; // store all the nodes that we've visited | |
int step = 0; // number of steps neeeded from root to current node | |
// initialize | |
add root to queue; | |
add root to visited; |
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
/** | |
* Return the length of the shortest path between root and target node. | |
*/ | |
int BFS(Node root, Node target) { | |
Queue<Node> queue; // store all nodes which are waiting to be processed | |
int step = 0; // number of steps neeeded from root to current node | |
// initialize | |
add root to queue; | |
// BFS | |
while (queue is not empty) { |
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
// Implementation of circular queue | |
package main | |
import "fmt" | |
type MyCircularQueue struct { | |
data []int | |
head int | |
tail int | |
size int |
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
// Basic implementation for queue | |
package main | |
import "fmt" | |
type queue struct { | |
data []int | |
head int | |
} |
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
// Min Heap implementation | |
// We will be performing following operations on the min heap | |
// a) Add a new element (add) | |
// b) Fetch top element (peek) | |
// c) Delete top element (pop) | |
package main | |
import "fmt" | |
type minHeap struct { |
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
// Max Heap implementation | |
// We will be performing following operations on the max heap | |
// a) Add a new element (add) | |
// b) Fetch top element (peek) | |
// c) Delete top element (pop) | |
package main | |
import "fmt" | |
type maxHeap struct { |