Skip to content

Add category #34

@ChrisVilches

Description

@ChrisVilches

This bit is used in at least three problems. It's pretty useful and I don't think there's a name for it:

  L[0] = 0;
  for (int i = 1; i < N; i++) {
    L[i] = i - 1;
    while (heights[L[i]] <= heights[i] && L[i] > 0) L[i] = L[L[i]];
  }

  R[N - 1] = N - 1;
  for (int i = N - 2; i >= 0; i--) {
    R[i] = i + 1;
    while (heights[R[i]] <= heights[i] && R[i] < N - 1) R[i] = R[R[i]];
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions