2.0.0 • Published 8 years ago

leetcode v2.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

Leetcode Helper

API

List

var List = require('leetcode').List;

List.node

ListNode constructor, used to create a node in list.

ListNode.prototype.toArray

Convert a List to an array. Usually used for debug.

var List = require('leetcode').List;

// { val: 1, next: { val: 2, next: { val: 3, next: null } } }  
var l = List.create([1, 2, 3]);

// [1, 2, 3]
console.log(l.toArray());

List.create

Create a List with an array, return the head of the list which is a ListNode instance.

var List = require('leetcode').List;

// { val: 1, next: { val: 2, next: { val: 3, next: null } } }  
var l = List.create([1, 2, 3]);

List.toArray

Same as ListNode.prototype.toArray.

Tree

var Tree = require('leetcode').Tree;

Tree.node

TreeNode constructor, used to create a node in tree.

Tree.create

var tree = require('leetcode').Tree;
var eq = require('assert').equal;
var t1 = tree.create([1,null,2,3]);
var t2 = tree.create([1,null,2,3]);

// Notice: you should implement isSameTree youself
eq(isSameTree(t1, t2), true);

Create a Tree with an array, return the root of the tree which is a TreeNode instance. Please refer the Leetcode#faq for the rule.

LICENSE

ISC