{ "cells": [ { "cell_type": "markdown", "source": [ "Given `n` `points` on a 2D plane where `points[i] = [xi, yi]`, Return _ the\n", "**widest vertical area** between two points such that no points are inside the\n", "area._\n", "\n", "A **vertical area** is an area of fixed-width extending infinitely along the\n", "y-axis (i.e., infinite height). The **widest vertical area** is the one with\n", "the maximum width.\n", "\n", "Note that points **on the edge** of a vertical area **are not** considered\n", "included in the area.\n", "\n", "\n", "\n", "**Example 1:**\n", "\n", "![](https://assets.leetcode.com/uploads/2020/09/19/points3.png)​\n", "\n", "\n", "\n", " Input: points = [[8,7],[9,9],[7,4],[9,7]]\n", " Output: 1\n", " Explanation: Both the red and the blue area are optimal.\n", "\n", "\n", "**Example 2:**\n", "\n", "\n", "\n", " Input: points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]\n", " Output: 3\n", "\n", "\n", "\n", "\n", "**Constraints:**\n", "\n", " * `n == points.length`\n", " * `2 <= n <= 105`\n", " * `points[i].length == 2`\n", " * `0 <= xi, yi <= 109`" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "max_width_of_vertical_area (generic function with 1 method)" }, "metadata": {}, "execution_count": 1 } ], "cell_type": "code", "source": [ "# @lc code=start\n", "using LeetCode\n", "\n", "function max_width_of_vertical_area(points::Vector{Vector{Int}})\n", " sort!(points)\n", " return maximum(points[i][1] - points[i - 1][1] for i in 2 : length(points))\n", "end\n", "# @lc code=end" ], "metadata": {}, "execution_count": 1 }, { "cell_type": "markdown", "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" ], "metadata": {} } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.10.1" }, "kernelspec": { "name": "julia-1.10", "display_name": "Julia 1.10.1", "language": "julia" } }, "nbformat": 4 }