Skip to content

Instantly share code, notes, and snippets.

View sourabh2k15's full-sized avatar
🎯
Focusing

sourabh2k15 sourabh2k15

🎯
Focusing
View GitHub Profile
https://www.reddit.com/r/AskElectronics/comments/2czxkg/fun_breadboard_projects_for_kids/
http://www.electronicshub.org/electronics-mini-project-circuits/
https://www.reddit.com/r/breadboard
https://startingelectronics.org/beginners/start-electronics-now/tut1-breadboard-circuits/
https://learn.adafruit.com/
<!DOCTYPE html>
<html>
<head>
<title>image processing </title>
</head>
<body>
<canvas id='picasso' style='border:1px solid red,float:left' width=400 height=300></canvas>
<canvas id='picasso2' width=400 height=300></canvas>
<script type='text/javascript'>
@sourabh2k15
sourabh2k15 / report.txt
Last active August 24, 2017 07:10
GSoC 2017 final report
GSoC Final Evaluation Report
# Project Goal
Enable Genoverse genome browser to parse and render large genomic binary data formats like Bigwig, Bigbed and compressed VCF. In order to do so I wrote javascript parsers for these file formats and the rendering code ( wherever it was missing ). I also wrote code to support the simpler text formats of Wiggle and BED in order to make the code simpler for the binary versions ( bigwig and bigbed ).
# List of Commits
https://github.com/wtsi-web/Genoverse/commits/gh-pages?author=sourabh2k15
defmodule Async do
@n_clients 100000
def createFollowersSync(n_clients) do
Enum.reduce(1..n_clients, [], fn rank, acc ->
acc ++ [Util.pickRandom(@n_clients, rank)]
end)
end
def createFollowersAsync(n_clients) do
@sourabh2k15
sourabh2k15 / inorderTraversal.cpp
Created December 26, 2017 01:33
Leetcode #94 Inorder Traversal of Binary Tree
class Solution {
public:
vector<int> inorderTraversal(TreeNode* root) {
vector<int> inorder;
stack<TreeNode*> nodes;
if(root == NULL) return inorder;
while(root != NULL || !nodes.empty()){
//push left children if available
@sourabh2k15
sourabh2k15 / isValidBST.cpp
Created December 26, 2017 01:35
Leetcode #98 Validate if Tree is BST
class Solution {
public:
bool isValidBST(TreeNode* root) {
if(root == NULL) return true;
stack<TreeNode*> s;
TreeNode* prev = NULL;
while(root != NULL || !s.empty()){
while(root != NULL){
@sourabh2k15
sourabh2k15 / KthSmallest.cpp
Created December 26, 2017 01:36
Leetcode #230 Find Kth Smallest element in BST
class Solution {
public:
int kthSmallest(TreeNode* root, int k) {
stack<TreeNode*> s;
while(root != NULL || !s.empty()){
while(root != NULL){
s.push(root);
root = root->left;
}
@sourabh2k15
sourabh2k15 / isValidSerialization.cpp
Created December 26, 2017 02:16
Leetcode #331. Verify Preorder Serialization of a Binary Tree
class Solution {
public:
/*
Intuition:
1) every node has to be a left or right child of some node, except the root ofcourse
2) every non "#" node means it has 2 leaves so a valid preorder string would have 2 more values
3) Using 1 and 2, set totalnodes = 0. Add 2 to totalnodes if non "#" value encountered and decrement totalnodes for having processed present value
4) Using this scheme, totalnodes should equal 0 at end if it's a valid preorder string.
5) We start with totalnodes = 1 instead of 0 cause inside loop it does totalnodes-- for every value , which includes
root value as well.
@sourabh2k15
sourabh2k15 / Trie.cpp
Created December 26, 2017 04:13
Leetcode #208 Simple Trie Implementation
class Trie {
private:
class TrieNode{
public:
bool isWord;
vector<TrieNode*> next;
TrieNode() : next(vector<TrieNode*>(26, NULL)), isWord(false){}
~TrieNode(){
for(auto node: next) delete node;
@sourabh2k15
sourabh2k15 / friendCircleNum.cpp
Last active January 4, 2018 06:52
Leetcode #547 Friend Circles
class Solution {
public:
// M is the friend matrix provided | basic intuition: we need connected components in graph, which can be done by BFS / DFS.
// why does this work ? because applying transitive property to this : a friend of b, b friend of c , c friend of d
// a,b,c,d should fall into 1 friend circle, just imagine a,b,c,d to be nodes of graph and they are connected by an edge if they
// are friends else not connected by an edge, so simply finding the total groups / connected components gives us the answer.
int findCircleNum(vector<vector<int>>& M) {
vector<bool> friendZoned(M.size(), false); // array to keep track of visited in DFS
stack<int> dfs; // stack to execute DFS