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
var kthSmallest = function(root, k) { | |
//input is tree | |
//output is value of node | |
//k value is always less than or equal to no.of nodes of tree | |
//space = linear and time = | |
//sort array in ascending order using tree traversal in to array | |
// storage for array | |
//pick k-1 th element | |
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
//pascal's triangle | |
var pascals = function(number) { | |
var initial = [[1], [1, 1]]; | |
if (number === 0) {return []}; | |
if (number === 1) {return [initial[0]]}; | |
if (number === 2) {return initial}; | |
var count = 2; | |
var recurse = function() { | |
if (count === number) { |
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
// Node.js CheatSheet. | |
// Download the Node.js source code or a pre-built installer for your platform, and start developing today. | |
// Download: http://nodejs.org/download/ | |
// More: http://nodejs.org/api/all.html | |
// 0. Synopsis. | |
// http://nodejs.org/api/synopsis.html |