Skip to content

zhiyelee/node-leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Leetcode helper library, such as create List, Tree from array

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published