Skip to content

Commit

Permalink
Update LongestPalindromicSubstring For Swift 5
Browse files Browse the repository at this point in the history
- cast strings directly to an array of Chars
- count property of String type is available
  • Loading branch information
normand1 authored Jun 1, 2019
1 parent b2e7678 commit c0d132d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DP/LongestPalindromicSubstring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class LongestPalindromicSubstring {
func longestPalindrome(_ s: String) -> String {
guard s.characters.count > 1 else {
guard s.count > 1 else {
return s
}

var sChars = [Character](s.characters)
var sChars = Array(s)
let len = sChars.count
var maxLen = 1
var maxStart = 0
Expand Down

0 comments on commit c0d132d

Please sign in to comment.