This file contains hidden or 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
| 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{ |
This file contains hidden or 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
| // 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){ |
This file contains hidden or 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
| /** | |
| * 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]; |
This file contains hidden or 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
| 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{ |
OlderNewer