Tap here to switch tabs
Problem
Submissions

Problem: Finding the Number of Visible Mountains

Try to solve the Finding the Number of Visible Mountains problem.

Statement

You are given a 00 indexed 22D integer array peaks where peaks[i] = [x_i, y_i] represents the peak coordinates of the iith mountain.

Each mountain is shaped as an isosceles right triangle with its base on the x axis and its right angle at the peak (x_i, y_i). A mountain covers the horizontal interval from xi−yix_i - y_i to xi+yix_i + y_i on the line y=0y = 0.

A mountain is considered visible if its peak does not lie strictly inside or on the boundary of any other mountain.

Return the total number of visible mountains.

Note: If multiple mountains have the exact same peak coordinates, they completely overlap and none of them are considered visible.

Constraints:

  • 1≤1 \leq peaks.length ≤105\leq 10^5

  • peaks[i].length =2= 2

  • 1≤1 \leq x_i, y_i ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Finding the Number of Visible Mountains

Try to solve the Finding the Number of Visible Mountains problem.

Statement

You are given a 00 indexed 22D integer array peaks where peaks[i] = [x_i, y_i] represents the peak coordinates of the iith mountain.

Each mountain is shaped as an isosceles right triangle with its base on the x axis and its right angle at the peak (x_i, y_i). A mountain covers the horizontal interval from xi−yix_i - y_i to xi+yix_i + y_i on the line y=0y = 0.

A mountain is considered visible if its peak does not lie strictly inside or on the boundary of any other mountain.

Return the total number of visible mountains.

Note: If multiple mountains have the exact same peak coordinates, they completely overlap and none of them are considered visible.

Constraints:

  • 1≤1 \leq peaks.length ≤105\leq 10^5

  • peaks[i].length =2= 2

  • 1≤1 \leq x_i, y_i ≤105\leq 10^5