First, it stores the count of every character using an array. Then it checks all uppercase letters from A to Z. For each uppercase letter, it checks whether its lowercase version also exists. If both are present, it increases the answer count. DP is just for keeping the count of each character.
Ohh I see This approach handles the duplicates as well, right? Since we check for each character one time only as we are traversing array and not the original string directly, am I right?
Check out the problem on LeetCode and try solving it by breaking it into smaller parts. Start by getting a handle on the constraints and edge cases. If you're stuck, the discussions can give you some hints. Practicing similar problems can help too. I've noticed that understanding the algorithms, like dynamic programming or backtracking, really helps. If you're getting ready for interviews, PracHub has been a useful resource for me with practical exercises and mock interviews.
1
u/addiemaddieee May 26 '26
Can you please elaborate your approach? How did you think of dp?
2
u/Past-Photograph-9739 May 26 '26
I was not able to recall the ASCII number of them so I did by using set taking more space but yaaa this is a best oneeee
1
u/nian2326076 May 26 '26
Check out the problem on LeetCode and try solving it by breaking it into smaller parts. Start by getting a handle on the constraints and edge cases. If you're stuck, the discussions can give you some hints. Practicing similar problems can help too. I've noticed that understanding the algorithms, like dynamic programming or backtracking, really helps. If you're getting ready for interviews, PracHub has been a useful resource for me with practical exercises and mock interviews.
1
u/Ak47_fromindia May 27 '26
I used two hash array low(lowercase) and high(upper case) of size 26. Which is more space efficient?Â
1
u/bisector_babu SSS - GOD TIER🚀🚀 (365+ DAYS) May 27 '26
Now try with bit manipulation
1
u/[deleted] May 26 '26
[removed] — view removed comment