Skip to content

Commit cf25560

Browse files
committed
Record another "brute force" tip
1 parent 1b93def commit cf25560

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

content/misc/leetcode.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
+++
22
title="Leetcode"
33
date=2025-03-24
4-
updated = 2025-09-04
4+
updated = 2025-10-24
55
taxonomies = { tags = ["Misc"] }
66
+++
77

@@ -29,6 +29,13 @@ Coding up brute force is a good starting point but a better starting point is ju
2929
Add "digital" constraints like only looking at one variable at a time and then try to solve and see where you have repeated work and things like that which could cause the optimal solution to fall out.
3030
In the example problem once I [looked at Deepti](https://www.youtube.com/watch?v=zraEXluZLj0) manually solve it, the solution became obvious and I wasn't stuck anymore.
3131

32+
- [424. Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement)
33+
34+
Also note where information you track gets used.
35+
Is this example, [Neetcode](https://www.youtube.com/watch?v=gqXU1UyA8pk) was able to drop the constant 26 in the `O(26n)` down to 1 by tracking the max frequency.
36+
This works (also explained in the video) because the only time we can increase the result is when we find a new max.
37+
Before that it really doesn't matter, so having a max that is too high does not have negative side effects.
38+
3239
</details>
3340

3441
## Tips for detecting DP

0 commit comments

Comments
 (0)