Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions MIT.LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2008-2014 Pivotal Labs

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 changes: 49 additions & 0 deletions linked_list/00-implement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

class LinkedListNode{
constructor(val){
this._value = val;
}
get value() {
return this._value;
}
set value(val) {
this._value = val;
}
get next(){
return this._next;
}
set next(nxt){
this._next = nxt;
}
}

class LinkedList {
constructor(){
this.sentinel = new LinkedListNode(null);
}
get head(){
return this.sentinel.next;
}
insert(val) {
var node = new LinkedListNode(val);
node.next = this.sentinel.next;
this.sentinel.next = node;
}
delete(){
if(this.sentinel.next){
this.sentinel.next=this.sentinel.next.next;
}
}
}


// var ll = new LinkedList();
// ll.insert(1);
// console.log(ll);
// ll.insert(2);
// console.log(ll);
// ll.insert(2);


module.exports.LinkedList = LinkedList;
17 changes: 17 additions & 0 deletions linked_list/01-find-nth-node-value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Write a function that takes 2 arguments; a linked list (ll) and on integer(n).
// The function should return the value of the nth node in the linked list.
//
// Assume that the linked is in non-empty and is of length at least 'n'

var ll = require('./00-implement');

function valueOfNthNode(ll, n){
var currentNode = ll.head;
for(var i=0;i<n-1;i++){
currentNode = currentNode.next
}
return currentNode.value
}


module.exports.valueOfNthNode = valueOfNthNode;
1 change: 1 addition & 0 deletions node_modules/.bin/cake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/coffee

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jasmine-node

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/r.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/r_js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions node_modules/coffee-script/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/coffee-script/CNAME

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/coffee-script/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions node_modules/coffee-script/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions node_modules/coffee-script/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/coffee-script/bin/cake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/coffee-script/bin/coffee

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions node_modules/coffee-script/bower.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 135 additions & 0 deletions node_modules/coffee-script/lib/coffee-script/browser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading