All Posts

Leetcode 540: Single Element in a Sorted Array

You are given a sorted array where every element appears exactly twice, except for one element which appears only once. Find and return the single element that does not have a pair.

Leetcode 542: 01 Matrix

Given an m x n binary matrix, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1.

Leetcode 553: Optimal Division

Given an array of integers, you need to add parentheses in such a way that the division expression evaluates to the maximum possible value. The division must respect the adjacency of integers in the array.

Leetcode 554: Brick Wall

Given a rectangular wall made up of bricks with varying widths, your task is to determine the minimum number of bricks that a vertical line crosses. The line should be drawn such that it does not cross any brick’s edge, and you cannot place the line at the edges of the wall.

Leetcode 560: Subarray Sum Equals K

Given an array nums of integers and an integer k, find the total number of contiguous subarrays whose sum equals k.

Leetcode 565: Array Nesting

You are given an array nums, a permutation of numbers from [0, n-1], and for each index k, you need to build a set s[k] by repeatedly selecting elements based on the rule nums[k] -> nums[nums[k]] -> nums[nums[nums[k]]], stopping when a duplicate is found. Return the longest length of any such set s[k].