M='aabc' becomes inventory: a→2, b→1, c→1. We no longer care where the characters are — only how many remain. #hashtables#python Watch: https://t.co/UrHo5rOh8n
Brute force asks: where is another unused character? Optimized asks: how many do I have left? That shift changes the whole solution. #hashtables#algorithms Watch: https://t.co/UrHo5rOh8n
Bad inventory flow: search stock records again for every unit. Better flow: item → available count → decrement. Same optimization idea. #softwareengineering Watch: https://t.co/qpq1NQgWjz
We track used positions, but what we really need is available quantity by character. That is the clue toward hashing. #hashtables#optimization Watch: https://t.co/qpq1NQgWjz
The code is correct, but every requirement can trigger another scan. Correctness and efficiency are two different questions. #algorithms Watch: https://t.co/C3XuxAvNTX
Next requirement, inner loop starts again. The debugger makes the repeated magazine scan obvious. #algorithms#optimization Watch: https://t.co/C3XuxAvNTX
The code is correct, but every requirement can trigger another scan. Correctness and efficiency are two different questions. #algorithms Watch: https://t.co/BX20JzJBdO
Next requirement, inner loop starts again. The debugger makes the repeated magazine scan obvious. #algorithms#optimization Watch: https://t.co/BX20JzJBdO
@RyanJ_KOL Yes a frequency map will help if we are only concerned about count
But that is where the hash comes in for the brute force iteration is the key to showing waste
No available copy after the scan? Return False immediately. If a mandatory resource can't be fulfilled, the whole request fails. #algorithms#softwareengineering