All Posts

Leetcode 973: K Closest Points to Origin

Given an array of points on a 2D plane, find the k closest points to the origin (0, 0) based on Euclidean distance. If multiple points have the same distance, any order is acceptable.

Leetcode 974: Subarray Sums Divisible by K

Given an integer array nums and an integer k, return the number of non-empty subarrays where the sum of elements is divisible by k. A subarray is defined as a contiguous sequence of elements in the array.

Leetcode 978: Longest Turbulent Subarray

Given an integer array arr, return the length of the largest subarray that is turbulent. A subarray is considered turbulent if the comparison sign alternates between each adjacent pair of elements.

Leetcode 979: Distribute Coins in Binary Tree

You are given a binary tree with n nodes, where each node contains node.val coins. There are exactly n coins in total across the tree. In one move, you can transfer a coin between two adjacent nodes (parent to child or child to parent). Return the minimum number of moves required to ensure that every node has exactly one coin.

Leetcode 981: Time Based Key-Value Store

Design a time-based key-value data structure that stores multiple values for the same key at different timestamps and supports retrieving the value at a specific timestamp.

Leetcode 983: Minimum Cost For Tickets

You are planning a series of train travels throughout the year. The days you plan to travel are given in a list of integers, where each integer represents a day of the year (from 1 to 365). You need to find the minimum cost needed to cover all the travel days using 1-day, 7-day, and 30-day passes.