Post

Jacob Bartlett
Jacob Bartlett@jacobtechtavern·
LeetCode Grind: Longest Palindrome This one was clean. I sort of just brute-forced it with my thinking and then ended up coming up with a solution that worked. It felt janky. It did not feel clean, but I got there in the end. This is like the third or fourth question I've done today that involves counting the number of characters by condensing them into a dictionary. I looked at the solutions, and they were of a very different shape, but actually they all just seemed like a less well-explained version of my one. If you enjoyed this post, join my newsletter at join.jacobstechtavern.com for more in-depth iOS content to help you maximise your salary.
Jacob Bartlett tweet mediaJacob Bartlett tweet media
English
1
0
8
651
iOS Developer Zone
iOS Developer Zone@iOSDevZone·
@jacobtechtavern Check out reduce(into:) and [_,default:] let's you write the whole first portion of your code like this: let dict = s.reduce(into: [Character: Int]()) { d,char in d[char, default: 0] += 1 } Very handy for these Leet Code problems.
English
0
0
0
26
Paylaş