Skip to content

Instantly share code, notes, and snippets.

View dineshrajpurohit's full-sized avatar

Dinesh Purohit dineshrajpurohit

View GitHub Profile
public Boolean isValidBinary(BinaryTreeNode root, BinaryTreeNode prev){
// Stack 3 2 1
// 1 2 3
// if(current.left != null ){
// Boolean left = isValidBinary(current.left);
// if(left == false)
// return false;
// else{
// Sieve of erosthenes
public static void primes(int n){
Boolean[] prime = new Boolean[n+1];
for(int i=2;i<=n;i++){
prime[i] = true;
}
for(int div=2;div*div<=n;div++){
if(prime[div] == true){
/**
* Dinesh
*
*/
//package com.dinesh.tutorials;
public static void pascal(int n){
int[][] pas = new int[n][];
for(int i=0; i<n;i++){
pas[i] = new int[i+1];
@dineshrajpurohit
dineshrajpurohit / exercise-fibonacci-closure.go
Created January 30, 2017 09:33
Fibonacci using closure in Go - Excercise
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
x := 0
y := 1
return func() int{