Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Run binary search twice. The first search is left-biased: when it finds the target, it records the index and keeps searching left. The second is right-biased and keeps searching right. Together they find both boundaries.
Running binary search twice with different bias — left-biased continues searching left even after finding a match to find the first occurrence, right-biased does the opposite.
Updated Feb 2026