All Posts

Leetcode 1104: Path In Zigzag Labelled Binary Tree

You are given a label representing a node in an infinite binary tree. In this binary tree, each level alternates between left-to-right and right-to-left labeling. Your task is to return the path from the root of the tree to the node with the given label, following the zigzag pattern.

Leetcode 1131: Maximum of Absolute Value Expression

You are given two arrays arr1 and arr2 of integers, both having equal lengths. Calculate the maximum value of the expression: |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j| for all pairs of indices i and j, where 0 <= i, j < arr1.length.

Leetcode 1137: N-th Tribonacci Number

The Tribonacci sequence is defined by the following recurrence relation: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given an integer n, return the value of Tn.

Leetcode 1140: Stone Game II

Alice and Bob are playing a game with piles of stones. Each pile contains a positive integer number of stones. On each player’s turn, they can take stones from the first X remaining piles, where 1 <= X <= 2M. The goal is to maximize the number of stones Alice can collect assuming both play optimally.

Leetcode 1201: Ugly Number III

An ugly number is a positive integer that is divisible by at least one of the integers a, b, or c. Your task is to return the nth ugly number in the sequence formed by the integers divisible by a, b, or c.

Leetcode 1227: Airplane Seat Assignment Probability

There are n passengers boarding an airplane with n seats. The first passenger has lost their ticket and picks a random seat. The remaining passengers sit in their assigned seat if available or pick a random seat if their assigned seat is taken. Return the probability that the nth person gets their own seat.