Skip to content

Commit 95abef5

Browse files
Restyled by clang-format
1 parent 42626a6 commit 95abef5

25 files changed

+87
-79
lines changed

javascript/1-easy-two-sum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ const twoSum = (nums, target) => {
1010
return result;
1111
};
1212

13-
twoSum([2, 7, 11, 15], 9);
13+
twoSum([ 2, 7, 11, 15 ], 9);

javascript/11-container-with-most-water.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var maxArea = function(height) {
1414
// Update the maximum area
1515
maxArea = Math.max(maxArea, currentArea);
1616

17-
//Move the pointer with the smaller height
17+
// Move the pointer with the smaller height
1818
if (height[left] < height[right]) {
1919
left++;
2020
} else {

javascript/125-validPalindrom.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @param {string} s
1515
* @return {boolean}
1616
*/
17-
var isPalindrome = function (s) {
17+
var isPalindrome = function(s) {
1818
let str = s.toLowerCase();
1919
let finalStr = '';
2020
for (let i = 0; i < str.length; i++) {
@@ -23,15 +23,18 @@ var isPalindrome = function (s) {
2323
finalStr += str[i];
2424
}
2525
}
26-
if (finalStr === finalStr.split('').reverse().join('')) return true;
26+
if (finalStr === finalStr.split('').reverse().join(''))
27+
return true;
2728
return false;
2829
};
2930

3031
const checkAsciiValue = (value) => {
31-
if (value.charCodeAt(0) >= 97 && value.charCodeAt(0) <= 122) return true;
32-
if (value.charCodeAt(0) >= 48 && value.charCodeAt(0) <= 57) return true;
32+
if (value.charCodeAt(0) >= 97 && value.charCodeAt(0) <= 122)
33+
return true;
34+
if (value.charCodeAt(0) >= 48 && value.charCodeAt(0) <= 57)
35+
return true;
3336
return false;
3437
};
3538

3639
console.log(isPalindrome('A man, a plan, a canal: Panama'));
37-
//console.log(isPalindrome('0p'));
40+
// console.log(isPalindrome('0p'));

javascript/13-easy-romatToInt.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const romanToInt = (s) => {
22
const roman = {
3-
I: 1,
4-
V: 5,
5-
X: 10,
6-
L: 50,
7-
C: 100,
8-
D: 500,
9-
M: 1000,
3+
I : 1,
4+
V : 5,
5+
X : 10,
6+
L : 50,
7+
C : 100,
8+
D : 500,
9+
M : 1000,
1010
};
1111
let sum = 0;
1212
for (let i = 0; i < s.length; i++) {

javascript/136-singleNumber.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @param {number[]} nums
33
* @return {number}
44
*/
5-
var singleNumber = function (nums) {
5+
var singleNumber = function(nums) {
66
let length = nums.length;
77
let uniqueVal;
88
for (let i = 0; i < length; i++) {
@@ -16,4 +16,4 @@ var singleNumber = function (nums) {
1616
return uniqueVal;
1717
};
1818

19-
console.log(singleNumber([4, 1, 2, 1, 2]));
19+
console.log(singleNumber([ 4, 1, 2, 1, 2 ]));
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
const longestCommonPrefix = (strs) => {
2-
if (strs.length === 0) return '';
2+
if (strs.length === 0)
3+
return '';
34
let result = '';
45
for (let i = 0; i < strs[0].length; i++) {
56
for (let j = 1; j < strs.length; j++) {
6-
if (strs[j][i] !== strs[0][i]) return result;
7+
if (strs[j][i] !== strs[0][i])
8+
return result;
79
}
810
result += strs[0][i];
911
}
1012
return result;
1113
};
1214

13-
console.log(longestCommonPrefix(['flower', 'flow', 'flight']));
15+
console.log(longestCommonPrefix([ 'flower', 'flow', 'flight' ]));

javascript/20-easy-validParenthesis.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
const isValid = (str) => {
2-
if (str.length % 2 !== 0) return false;
2+
if (str.length % 2 !== 0)
3+
return false;
34
const stack = [];
45
const map = {
5-
'(': ')',
6-
'[': ']',
7-
'{': '}',
6+
'(' : ')',
7+
'[' : ']',
8+
'{' : '}',
89
};
910
for (let i = 0; i < str.length; i++) {
1011
if (str[i] === '(' || str[i] === '[' || str[i] === '{') {

javascript/205-isomorphicCharacter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
var isIsomorphic = function (s, t) {
2+
var isIsomorphic = function(s, t) {
33
let map = new Map();
44
let map2 = new Map();
55
for (let i = 0; i < s.length; i++) {
@@ -16,5 +16,5 @@ var isIsomorphic = function (s, t) {
1616
};
1717

1818
console.log(isIsomorphic('egg', 'add'));
19-
//console.log(isIsomorphic('ffo', 'bar'));
20-
//console.log(isIsomorphic('paper', 'title'));
19+
// console.log(isIsomorphic('ffo', 'bar'));
20+
// console.log(isIsomorphic('paper', 'title'));
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const mergeTwoLists = (l1, l2) => {
2-
if (!l1) return l2;
3-
if (!l2) return l1;
2+
if (!l1)
3+
return l2;
4+
if (!l2)
5+
return l1;
46
if (l1.val < l2.val) {
57
l1.next = mergeTwoLists(l1.next, l2);
68
return l1;
@@ -9,4 +11,4 @@ const mergeTwoLists = (l1, l2) => {
911
return l2;
1012
};
1113

12-
console.log(mergeTwoLists([1, 2, 4], [1, 3, 4]));
14+
console.log(mergeTwoLists([ 1, 2, 4 ], [ 1, 3, 4 ]));

javascript/217-containsDuplicate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
* @param {number[]} nums
2323
* @return {boolean}
2424
*/
25-
var containsDuplicate = function (nums) {
25+
var containsDuplicate = function(nums) {
2626
let unique = new Set(nums);
2727
return unique.size !== nums.length;
2828
};
2929

30-
console.log(containsDuplicate([1, 2, 3, 4]));
30+
console.log(containsDuplicate([ 1, 2, 3, 4 ]));

0 commit comments

Comments
 (0)