2 ms·
This is also essentially the trick applied in Kadane's Algorithm for the "maximum contiguous sum" search, albeit using masks to "undo" the set-of-characters che
by jvanderbot 4y ago
This is also essentially the trick applied in Kadane's Algorithm for the "maximum contiguous sum" search, albeit using masks to "undo" the set-of-characters check whereas Kadane's uses subtraction to "undo" the addition for maximum sum check.
https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/ https://www.geeksforgeeks.org/largest-sum-contiguous-subarra...
- krackers 4y agoKadane's algorithm (whose name sounds cooler than what it does) doesn't do any masks, it basically just keeps extending the window until the sum becomes negative at which point it starts a new window.