Skip to content

Commit

Permalink
feat: 格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwenjie authored and xuwenjie committed Aug 19, 2019
1 parent 678236f commit 95109be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions String/Practice/characterCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -24,21 +23,19 @@ function getCount2(str) {
}

var num = 0;
var char = '';
var char = "";
for (var key in obj) {
if (obj[key] > num) {
num = obj[key];
char = key;
}
}

return { num, char }

return { num, char };
}


// test

var s = 'wewerereeeeeee2423432sdfdsff';
getCount(s)
getCount2(s)
var s = "wewerereeeeeee2423432sdfdsff";
getCount(s);
getCount2(s);
2 changes: 1 addition & 1 deletion leetcode/easy/validParentheses.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ function checkHtml(str) {
}


const temp = '<div id="first" class="red"><span>hello world! </span></div>';
const temp = '<div id="first" class="red"><span>hello world! </span></div>';

0 comments on commit 95109be

Please sign in to comment.