All Posts

Leetcode 1387: Sort Integers by The Power Value

The task is to find the kth integer in the range [lo, hi] sorted by the number of steps required to reach 1 using the Collatz conjecture rules. The power of a number is the number of steps needed to reach 1, following the rules: if the number is even, divide it by 2, and if it’s odd, multiply it by 3 and add 1.

Leetcode 1390: Four Divisors

Given an integer array nums, find the sum of divisors of all integers in that array that have exactly four divisors. If there are no such integers, return 0.

Leetcode 1391: Check if There is a Valid Path in a Grid

You are given an m x n grid where each cell represents a street. The streets have different connections between neighboring cells. Starting from the top-left corner of the grid, you need to find if there exists a valid path to the bottom-right corner, following the direction of the streets.

Leetcode 1395: Count Number of Teams

You are given a list of soldiers, each with a unique rating. You need to form teams of 3 soldiers from this list. A valid team is one where the soldiers’ ratings are either strictly increasing or strictly decreasing as we move from left to right in the team. The team must satisfy the condition that the indices (i, j, k) follow 0 <= i < j < k < n.

Leetcode 1396: Design Underground System

You are tasked with building a system to track customer travel times within an underground railway network. The system should calculate the average time taken to travel between two stations based on previous trips. Implement the UndergroundSystem class with the following methods.

Leetcode 1400: Construct K Palindrome Strings

You are given a string s and an integer k. Your task is to determine whether it’s possible to use all the characters in the string s to construct exactly k palindromic strings.