diff --git a/String/Practice/characterCount.js b/String/Practice/characterCount.js index 436af72..ddb55df 100644 --- a/String/Practice/characterCount.js +++ b/String/Practice/characterCount.js @@ -2,14 +2,13 @@ * 字符出现的次数 */ - function getCount(str) { - const arr = [...new Set(str.split(''))]; - let obj = {} + const arr = [...new Set(str.split(""))]; + let obj = {}; arr.forEach(k => { obj[k] = str.split(k).length - 1; - }) - return obj + }); + return obj; } function getCount2(str) { @@ -24,7 +23,7 @@ function getCount2(str) { } var num = 0; - var char = ''; + var char = ""; for (var key in obj) { if (obj[key] > num) { num = obj[key]; @@ -32,13 +31,11 @@ function getCount2(str) { } } - return { num, char } - + return { num, char }; } - // test -var s = 'wewerereeeeeee2423432sdfdsff'; -getCount(s) -getCount2(s) \ No newline at end of file +var s = "wewerereeeeeee2423432sdfdsff"; +getCount(s); +getCount2(s); diff --git a/leetcode/easy/validParentheses.js b/leetcode/easy/validParentheses.js index 1cf0f13..96d04bf 100644 --- a/leetcode/easy/validParentheses.js +++ b/leetcode/easy/validParentheses.js @@ -82,4 +82,4 @@ function checkHtml(str) { } -const temp = '
hello world!
'; \ No newline at end of file +const temp = '
hello world!
';