Skip to content

Commit 6231903

Browse files
author
mykoo
committed
valid-palindrome
1 parent 8ccbeb1 commit 6231903

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

โ€Žmissing-number/GUMUNYEONG.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var missingNumber = function (nums) {
1515
// TC
1616
// nums ์ •๋ ฌ์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ˆœํšŒ (๊ธธ์ด n) -> ์ตœ์„ ์˜ ๊ฒฝ์šฐ O(n) ์ด์ง€๋งŒ, ํ‰๊ท ์ ์œผ๋กœ O(n log n)
1717
// ๋น ์ง„ ์ˆซ์ž๋ฅผ ์ฐพ๊ธฐ์œ„ํ•ด์„œ ์ˆœํšŒ (์ตœ๋Œ€๊ธธ์ด n)
18-
// O(2n) ๋”ฐ๋ผ์„œ ์‹œ๊ฐ„ ๋ณต์žก๋„๋Š” O(n)
18+
// ๋”ฐ๋ผ์„œ ์‹œ๊ฐ„ ๋ณต์žก๋„๋Š” ์ตœ๋Œ€ O(n log n)
1919

2020
// SC
2121
// ๊ธธ์ด๊ฐ€ n์ธ ๋ฐฐ์—ด์„ ์ €์žฅํ•  ๊ณต๊ฐ„ ํ•„์š”

โ€Žvalid-palindrome/GUMUNYEONG.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55
var isPalindrome = function (s) {
66

7-
let str = newStr(s);
7+
let str = normalize(s);
88
let reverseStr = "";
99

10-
function newStr(str) {
10+
function normalize(str) {
1111
str = str.toLowerCase().replace(/[^a-z0-9]/g, "");
1212

1313
return str;
@@ -23,7 +23,7 @@ var isPalindrome = function (s) {
2323
};
2424

2525
// TC : O(n)
26-
// newStr ํ•จ์ˆ˜์—์„œ n๋ฒˆ(s์˜๊ธธ์ด) ์ˆœํšŒ(toLowerCase) + n๋ฒˆ ์ˆœํšŒ(replace)
26+
// normalize ํ•จ์ˆ˜์—์„œ n๋ฒˆ(s์˜๊ธธ์ด) ์ˆœํšŒ(toLowerCase) + n๋ฒˆ ์ˆœํšŒ(replace)
2727
// reverseStr ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ for๋ฌธ - ๊ธธ์ด n
2828
// = O(3n) ๋”ฐ๋ผ์„œ O(n)
2929

0 commit comments

Comments
ย (0)