Longest Palindromic Subsequence
Signals to notice
Brute force first
Generate all subsequences and check which are palindromes. Exponential. That instinct is useful because it follows the prompt literally, but it usually keeps revisiting work the problem is begging you to organize.
The key insight
The LPS of string s equals the LCS of s and reverse(s). Use the standard LCS DP. Alternatively, interval DP: dp[i][j] = LPS length of s[i.j]. If s[i]==s[j], dp[i][j] = dp[i+1][j-1] + 2. Else max(dp[i+1][j], dp[i][j-1]). Once you hold onto the right piece of information from moment to moment, the problem feels less like trial and error and more like following a shape that was there all along.
What must stay true
A palindrome reads the same forwards and backwards. The longest palindromic subsequence is equivalent to the longest common subsequence between the string and its reverse — characters that appear in matching order from both ends. When you keep that truth intact, each local choice supports the larger solution instead of fighting it.
Easy way to go wrong
Confusing palindromic SUBSEQUENCE with palindromic SUBSTRING — subsequences don't need to be contiguous. The DP allows skipping characters. Most mistakes here are not about syntax; they come from losing track of what your state, pointer, or structure is supposed to mean.