Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 868ef8f

Browse files
authored
Renamed log[] to lg[] to prevent ambiguous error in sparse table (#817)
1 parent 1fd75e6 commit 868ef8f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/data_structures/sparse-table.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ This requires that we are able to compute $\log_2(R - L + 1)$ fast.
9797
You can accomplish that by precomputing all logarithms:
9898

9999
```{.cpp file=sparse_table_log_table}
100-
int log[MAXN+1];
101-
log[1] = 0;
100+
int lg[MAXN+1];
101+
lg[1] = 0;
102102
for (int i = 2; i <= MAXN; i++)
103-
log[i] = log[i/2] + 1;
103+
lg[i] = lg[i/2] + 1;
104104
```
105105

106106
Afterwards we need to precompute the Sparse Table structure. This time we define $f$ with $f(x, y) = \min(x, y)$.
@@ -119,7 +119,7 @@ for (int j = 1; j <= K; j++)
119119
And the minimum of a range $[L, R]$ can be computed with:
120120

121121
```{.cpp file=sparse_table_minimum_query}
122-
int j = log[R - L + 1];
122+
int j = lg[R - L + 1];
123123
int minimum = min(st[L][j], st[R - (1 << j) + 1][j]);
124124
```
125125

0 commit comments

Comments
 (0)