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- }
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+ }
1515}
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- }
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+ }
1515}
You can’t perform that action at this time.
0 commit comments