Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3f8db60

Browse files
authored
Merge pull requestneetcode-gh#2417 from krishna1m/0125-valid-palindrome
Create 0125-valid-palindrome.scala
2 parents4e8e4de +d2dc41b commit3f8db60

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎scala/0125-valid-palindrome.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
objectSolution {
2+
defisPalindrome(s:String):Boolean= {
3+
valsmallCased= s.toLowerCase
4+
// removing all non-alphanumeric characters
5+
valnotAlphaNumericRegex="""[\W_]""".r
6+
valtoCompareWith= notAlphaNumericRegex.replaceAllIn(smallCased,"")
7+
8+
valreversed= toCompareWith.reverse
9+
toCompareWith== reversed
10+
}
11+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp