This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[]} nums | |
| * @return {number[]} | |
| */ | |
| var minBitwiseArray = function(nums) { | |
| const ans = new Array(nums.length); | |
| for (let i = 0; i < nums.length; i++) { | |
| const p = nums[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[]} nums | |
| * @return {number[]} | |
| */ | |
| var minBitwiseArray = function(nums) { | |
| const ans = new Array(nums.length); | |
| for (let i = 0; i < nums.length; i++) { | |
| const p = nums[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[][]} mat | |
| * @param {number} threshold | |
| * @return {number} | |
| */ | |
| var maxSideLength = function(mat, threshold) { | |
| const m = mat.length; | |
| const n = mat[0].length; | |
| // ----------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[][]} grid | |
| * @return {number} | |
| */ | |
| var largestMagicSquare = function(grid) { | |
| const m = grid.length; | |
| const n = grid[0].length; | |
| // Helper: check if the k×k square starting at (r, c) is magic | |
| function isMagic(r, c, k) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[][]} bottomLeft | |
| * @param {number[][]} topRight | |
| * @return {number} | |
| */ | |
| var largestSquareArea = function(bottomLeft, topRight) { | |
| let n = bottomLeft.length; | |
| let maxArea = 0; | |
| // Compare every pair of rectangles (i, j) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number} m | |
| * @param {number} n | |
| * @param {number[]} hFences | |
| * @param {number[]} vFences | |
| * @return {number} | |
| */ | |
| var maximizeSquareArea = function(m, n, hFences, vFences) { | |
| const MOD = 1_000_000_007; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number} n | |
| * @param {number} m | |
| * @param {number[]} hBars | |
| * @param {number[]} vBars | |
| * @return {number} | |
| */ | |
| var maximizeSquareHoleArea = function(n, m, hBars, vBars) { | |
| /** | |
| * Finds the longest run of consecutive integers in an array. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[][]} squares | |
| * @return {number} | |
| */ | |
| var separateSquares = function (squares) { | |
| // ------------------------------------------------------------ | |
| // BUILD SWEEP EVENTS + COLLECT ALL X-COORDINATES | |
| // ------------------------------------------------------------ | |
| // For each square: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[][]} squares | |
| * @return {number} | |
| */ | |
| var separateSquares = function (squares) { | |
| // ------------------------------------------------------------ | |
| // STEP 1: Compute total area (counting overlaps multiple times) | |
| // ------------------------------------------------------------ | |
| let totalArea = 0; | |
| for (const [x, y, l] of squares) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[][]} points | |
| * @return {number} | |
| */ | |
| var minTimeToVisitAllPoints = function(points) { | |
| // Total time accumulator | |
| let totalTime = 0; | |
| // Iterate through each consecutive pair of points | |
| for (let i = 1; i < points.length; i++) { |
NewerOlder