File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import java .util .HashSet ;
2+
3+ class Solution {
4+ public boolean containsDuplicate (int [] nums ) {
5+ HashSet <Integer > set = new HashSet <>();
6+
7+ for (int num : nums ) {
8+ if (!set .add (num )) {
9+ return true ;
10+ }
11+ }
12+
13+ return false ;
14+ }
15+ }
16+
Original file line number Diff line number Diff line change 1+ class Solution {
2+ public boolean isPalindrome (String s ) {
3+
4+ // ๋ฌธ์์ด s์ ๋๋ฌธ์๋ฅผ ์๋ฌธ์๋ก ์นํํ๋ค.
5+ String lowerCase = s .toLowerCase ();
6+ // ์๋ฌธ์ a-z, ์ซ์ 0-9์ ํด๋นํ์ง ์๋ ๋ฌธ์๋ฅผ ์ง์ด๋ค.
7+ String alphanumeric = lowerCase .replaceAll ("[^a-z0-9]" , "" );
8+ // ๋ค์ง์ ๋ฌธ์์ด์ ๋ง๋ ๋ค.
9+ String reverse = new StringBuilder (alphanumeric ).reverse ().toString ();
10+ // ๋ ๋ฌธ์์ด์ ๋น๊ตํ๋ค.
11+ boolean isEqual = alphanumeric .equals (reverse );
12+
13+ return isEqual ;
14+ }
15+ }
16+
You canโt perform that action at this time.
0 commit comments