
g0101_0200.s0131_palindrome_partitioning.Solution.swift Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming
// #Backtracking #Big_O_Time_O(N*2^N)_Space_O(2^N*N)
// #2024_06_27_Time_454_ms_(98.01%)_Space_37.7_MB_(5.11%)
class Solution {
func partition(_ s: String) -> [[String]] {
var dict:[Int:[[String]]] = [:]
var newStr = Array(s)
dict[-1] = [[]]
for i in 0..Bool{
let strArr = Array(str)
var valid = true
var l = 0
var r = strArr.count - 1
while(l<=r){
if strArr[l] == strArr[r]{
l += 1
r -= 1
}else{
valid = false
break
}
}
return valid
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy