Skip to content

Commit 4a82a5b

Browse files
remove uselessrequires
1 parent 49438a3 commit 4a82a5b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+56
-205
lines changed

LeetcodeProblems/3Sum.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ A solution set is:
1818
[-1, -1, 2]
1919
]
2020
*/
21-
const assert = require('assert');
2221

2322
/**
2423
* @param {number[]} nums
@@ -49,26 +48,4 @@ var threeSum = function(nums) {
4948
return ret;
5049
};
5150

52-
var main = function() {
53-
test();
54-
}
55-
56-
var test = function () {
57-
assert.deepEqual(threeSum([]), []);
58-
assert.deepEqual(threeSum([0]), []);
59-
assert.deepEqual(threeSum([0, 0]), []);
60-
assert.deepEqual(
61-
threeSum([0, 0, 0]),
62-
[[0, 0, 0]]
63-
);
64-
assert.deepEqual(
65-
threeSum([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),
66-
[[0, 0, 0]]
67-
);
68-
assert.deepEqual(
69-
threeSum([-1, 0, 1, 2, -1, -4]),
70-
[ [ -1, 2, -1 ], [ 0, 1, -1 ] ]
71-
);
72-
}
73-
74-
module.exports.main = main;
51+
module.exports.threeSum = threeSum;

LeetcodeProblems/Add_Two_Numbers.js

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ Explanation: 342 + 465 = 807.
2121
* this.next = null;
2222
* }
2323
*/
24-
const assert = require('assert');
25-
const ListNodeTestHelper = require('../utilsClasses/ListNodeTestHelper');
2624
var ListNode = require('../UtilsClasses/ListNode').ListNode;
27-
25+
2826
/**
2927
* @param {ListNode} l1
3028
* @param {ListNode} l2
@@ -64,31 +62,4 @@ var addTwoNumbers = function(l1, l2) {
6462
return head;
6563
};
6664

67-
var main = function() {
68-
test();
69-
}
70-
71-
function test() {
72-
const list1 = ListNode.linkenList([1,2,3,4]);
73-
const list2 = ListNode.linkenList([1,2,3,4]);
74-
ListNodeTestHelper.assertList(
75-
addTwoNumbers(list1, list2),
76-
[2, 4, 6, 8]
77-
);
78-
79-
const list3 = ListNode.linkenList([1]);
80-
const list4 = ListNode.linkenList([1,2]);
81-
ListNodeTestHelper.assertList(
82-
addTwoNumbers(list3, list4),
83-
[2, 2]
84-
);
85-
86-
const list5 = ListNode.linkenList([]);
87-
const list6 = ListNode.linkenList([1,2]);
88-
ListNodeTestHelper.assertList(
89-
addTwoNumbers(list5, list6),
90-
[1, 2]
91-
);
92-
}
93-
94-
module.exports.main = main;
65+
module.exports.addTwoNumbers = addTwoNumbers;

LeetcodeProblems/Award_Budget_Cuts.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ Constraints:
2929
3030
[output] double
3131
*/
32-
const assert = require('assert');
33-
3432
var cutAwardBadges = function(nums, newBadge) {
3533
var currentBadge = 0;
3634
for(var i = 0; i < nums.length; i++)
@@ -66,19 +64,4 @@ var findCap = function(nums, currentBadge, newBadge) {
6664
return nums[iter] + (-diff) / iter;
6765
}
6866

69-
var main = function() {
70-
test();
71-
}
72-
73-
function test() {
74-
assert.deepEqual(
75-
cutAwardBadges([2, 100, 50, 120, 1000], 190),
76-
[ 47, 47, 47, 47, 2 ]
77-
);
78-
assert.deepEqual(
79-
cutAwardBadges([2, 100, 50, 120, 1000], 5),
80-
[ 1, 1, 1, 1, 1 ]
81-
);
82-
}
83-
84-
module.exports.main = main;
67+
module.exports.cutAwardBadges = cutAwardBadges;

LeetcodeProblems/Backspace_String_Compare.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Follow up:
3131
3232
Can you solve it in O(N) time and O(1) space?
3333
*/
34-
const assert = require('assert');
3534

3635
/**
3736
* @param {string} S
@@ -106,20 +105,5 @@ var backspaceCompare2 = function(S, T) {
106105
return stackS.length === 0 && stackT.length === 0;
107106
};
108107

109-
var main = function() {
110-
test();
111-
}
112-
113-
function test() {
114-
assert.equal(backspaceCompare("ab#c", "ad#c"), true); // true
115-
assert.equal(backspaceCompare("ab##", "c#d#"), true); // true
116-
assert.equal(backspaceCompare("a##c", "#a#c"), true); // true
117-
assert.equal(backspaceCompare("a#c", "b"), false); // false
118-
119-
assert.equal(backspaceCompare2("ab#c", "ad#c"), true); // true
120-
assert.equal(backspaceCompare2("ab##", "c#d#"), true); // true
121-
assert.equal(backspaceCompare2("a##c", "#a#c"), true); // true
122-
assert.equal(backspaceCompare2("a#c", "b"), false); // false
123-
}
124-
125-
module.exports.main = main;
108+
module.exports.backspaceCompare = backspaceCompare;
109+
module.exports.backspaceCompare2 = backspaceCompare2;

LeetcodeProblems/Best_Time_To_Buy_And_Sell_Stock_II.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Input: [7,6,4,3,1]
2727
Output: 0
2828
Explanation: In this case, no transaction is done, i.e. max profit = 0.
2929
*/
30-
const assert = require('assert');
3130

3231
/**
3332
* @param {number[]} prices
@@ -65,4 +64,4 @@ function test() {
6564
assert.equal(maxProfit([7,1,5,3320,6,4]), 3319);
6665
}
6766

68-
module.exports.main = main;
67+
module.exports.maxProfit = maxProfit;

LeetcodeProblems/Binary_Gap.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Explanation:
3636
8 in binary is 0b1000.
3737
There aren't any consecutive pairs of 1's in the binary representation of 8, so we return 0.
3838
*/
39-
const assert = require('assert');
4039

4140
/**
4241
* @param {number} N
@@ -61,13 +60,4 @@ var binaryGap = function(N) {
6160
return maxDist;
6261
};
6362

64-
var main = function() {
65-
test();
66-
}
67-
68-
function test() {
69-
assert.equal(binaryGap(22), 2); // 10110
70-
assert.equal(binaryGap(8), 0); // 1000
71-
}
72-
73-
module.exports.main = main;
63+
module.exports.binaryGap = binaryGap;

LeetcodeProblems/Clone_Graph.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ You don't need to understand the serialization to solve the problem.
4040
* }
4141
*/
4242

43-
4443
// SOLUTION 1 Using DFS
4544
/**
4645
* @param {UndirectedGraphNode} graph

LeetcodeProblems/Coin_Change.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Output: -1
1818
Note:
1919
You may assume that you have an infinite number of each kind of coin.
2020
*/
21-
const assert = require('assert');
2221

2322
// Solution 3
2423
var coinChange = function(coins, amount) {
@@ -102,16 +101,4 @@ var min = function(a, b, c) {
102101
return (b < c) ? b : c;
103102
}
104103

105-
function main() {
106-
test();
107-
}
108-
109-
function test() {
110-
assert.equal(coinChange([], 3), -1);
111-
assert.equal(coinChange([2], 3), -1);
112-
assert.equal(coinChange([1, 2, 5], 11), 3);
113-
assert.equal(coinChange([3, 7, 405, 436], 8839), 25);
114-
assert.equal(coinChange([370, 417, 408, 156, 143, 434, 168, 83, 177, 280, 117], 9953), 24);
115-
}
116-
117-
module.exports.main = main;
104+
module.exports.coinChange = coinChange;

LeetcodeProblems/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ Return the following binary tree:
2727
* this.left = this.right = null;
2828
* }
2929
*/
30-
const assert = require('assert');
31-
3230
var TreeNode = require('../UtilsClasses/TreeNode').TreeNode;
3331

3432
/**
@@ -59,12 +57,4 @@ var buildTreeAux = function(preorder, pl, ph, inorder, il, ih) {
5957
return ret;
6058
}
6159

62-
var main = function() {
63-
test();
64-
}
65-
66-
function test() {
67-
console.log(buildTree([3,9,20,15,7], [9,3,15,20,7]));
68-
}
69-
70-
module.exports.main = main
60+
module.exports.buildTree = buildTree

LeetcodeProblems/Deletion_Distance.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ output: 9
1818
input: str1 = "", str2 = ""
1919
output: 0
2020
*/
21-
const assert = require('assert');
2221

2322
// Solution 3 Using DP
2423
var deletionDistanceDP = function(str1, str2) {
@@ -128,4 +127,7 @@ function test() {
128127
assert.equal(deletionDistanceDP("", ""), 0);
129128
}
130129

131-
module.exports.main = main
130+
module.exports.deletionDistance = deletionDistance;
131+
module.exports.deletionDistance2 = deletionDistance2;
132+
module.exports.deletionDistanceDP = deletionDistanceDP;
133+

0 commit comments

Comments
 (0)