All Posts

Leetcode 1015: Smallest Integer Divisible by K

Given a positive integer k, find the length of the smallest positive integer n such that n is divisible by k, and n consists only of the digit 1. If no such number exists, return -1. Note that n might not fit into a 64-bit signed integer.

Leetcode 1017: Convert to Base -2

Given a non-negative integer n, return its binary representation in base -2. The binary string should not have leading zeros unless the result is zero.

Leetcode 1033: Moving Stones Until Consecutive

You are given three stones located at different positions on the X-axis. The positions are represented by three distinct integers a, b, and c. In one move, you can pick a stone from either of the two endpoints (the smallest or the largest position) and move it to any unoccupied position between the two endpoints. The game ends when all three stones are positioned at three consecutive spots on the X-axis. Your task is to determine the minimum and maximum number of moves required to reach this configuration.

Leetcode 1040: Moving Stones Until Consecutive II

You are given a list of stones placed at different positions along the X-axis. A stone is considered an endpoint if it has the smallest or largest position. In one move, you can pick an endpoint stone and move it to any unoccupied position. The game ends when no more moves are possible, which occurs when the stones are in three consecutive positions. The goal is to find the minimum and maximum number of moves that can be made to achieve this configuration.

Leetcode 1073: Adding Two Negabinary Numbers

You are given two numbers represented in base -2. Each number is given as an array of binary digits (0s and 1s), where the most significant bit is at the beginning of the array. Your task is to add these two numbers together and return the result in the same format, as an array of 0s and 1s in base -2, without leading zeros.

Leetcode 1093: Statistics from a Large Sample

You are given a dataset of integers in the range [0, 255], represented by an array count where count[k] denotes the frequency of number k in the dataset. From this dataset, compute the following statistics: minimum, maximum, mean, median, and mode.