Pattern

Array

A compact view of archive entries grouped by recurring technique.

385 entries

385 entries tagged as Array.

10.05.2023

medium

59. Spiral Matrix II

to detect an empty cell, we can check it for == 0

Array is used to represent the matrix and store results. Iterative traversal of the matrix is used to fill the spiral pattern. Simulating a robot moving in a spiral pattern to fill the matrix. Checking boundaries and visited status before moving to the next cell. The problem involves generating a spiral matrix. Using 2D arrays to represent the matrix.

19.11.2022

hard

Erect The Fence

fun outerTrees(trees: Array): Array {

IntArray MutableList sort andrew's monotonic chain vector algebra for ccw check convex hull monotone chain

1.11.2022

medium

Where Will The Ball Fall

This is a geometry problem, but seeing the pattern might help. We can spot that each row is an action sequence: -1 -1 -1 shifts balls left, and 1 1 1 shifts balls to the right. Corners can be formed only with -1 1 sequence.

indToBall iterative_update tracking_ball_positions identifying_shift_rules grid_manipulation