File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ // ์
๋ ฅ๋ ๋ฌธ์ ์ค ์ํ๋ฒณ์ด๋ ์ซ์๊ฐ ์๋ ๊ฐ๋ค์ ํ๋์ ๋ฌธ์์ด๋ก ๋ง๋ ๋ค.
2+ // ์ด๋ ๋ชจ๋ ๋ฌธ์๋ค์ ์๋ฌธ์๋ก ๋ฐ๊พผ๋ค.
3+ // ์ญ์ ๋ ฌํ ๊ฐ๊ณผ ์๋ ๊ฐ์ ๋น๊ตํด ํฐ๋ฆฐ๋๋กฌ ์ ๋ฌด๋ฅผ ์ถ๋ ฅํ๋ค.
4+
5+ // ์ํ๋ฒณ ํน์ ์ซ์๊ฐ ์๋์ง ๊ฒ์ฌํ๋ ๋ฌธ์ -> charToCheck
6+
7+ // ์๊ฐ๋ณต์ก๋ : O(n)
8+ // ๊ณต๊ฐ๋ณต์ก๋ : O(n)
9+
10+ class Solution_Gotprgmer {
11+ static StringBuilder sb ;
12+ public boolean isPalindrome (String s ) {
13+ sb = new StringBuilder ();
14+ for (char charToCheck : s .toCharArray ()){
15+ if (!Character .isLetterOrDigit (charToCheck )){
16+ continue ;
17+ }
18+ sb .append (Character .toLowerCase (charToCheck ));
19+ }
20+ String originalDirection = sb .toString ();
21+ String reDirection = sb .reverse ().toString ();
22+
23+ if (originalDirection .equals (reDirection )){
24+
25+ return true ;
26+ }
27+ else {
28+ return false ;
29+ }
30+ }
31+ }
You canโt perform that action at this time.
0 commit comments