Skip to content

Commit 64b4e9a

Browse files
Update cf-1520F1.mdx
1 parent 10e3940 commit 64b4e9a

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

solutions/silver/cf-1520F1.mdx

+3-8
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@ author: Rameez Parwez
99

1010
## Explanation
1111

12-
To efficiently locate the $k$-th zero within a segment $[l, r]$, we utilize a binary search strategy. Initially, our segment encompasses the entire range $[l, r]$. The objective is to gradually narrow down this segment until we pinpoint the exact position of the $k$-th zero.
12+
We use binary search to find the location of the $k$th zero.
1313

14-
We start by defining the midpoint of the current segment as $m = \frac{l+r}{2}$. This allows us to divide the segment into two halves: $[l, m]$ and $[m+1, r]$.
15-
16-
Next, we perform a query to determine the number of zeros within the left half $[l, m]$. Let's denote this count as $x$. Based on the result:
17-
- If $x$ is greater than or equal to $k$, it indicates that at least $k$ zeros lie within the left half $[l, m]$. Therefore, we focus our search on this left segment $[l, m]$ to find the $k$-th zero.
18-
- If $x$ is less than k, then the $k$-th zero must lie in the right segment $[m+1, r]$. In this case, we adjust $k$ to $(k - x)$ and continue our search in the right segment $[m+1, r]$.
19-
20-
By following this iterative strategy, we continuously refine our search segment based on whether the $k$-th zero is expected to be in the left or right half. This systematic approach allows us to gradually narrow down the range $[l, r]$ until we pinpoint the exact position of the $k$-th zero.
14+
To do this, we set a midpoint and then check if the number of zeros in the left half is greater than or equal to or strictly less than $k$.
15+
This allows us to narrow the location of the $k$th zero to either the left or right half.
2116

2217
## Implementation
2318

0 commit comments

Comments
 (0)