All Posts

Leetcode 1436: Destination City

You are given an array paths where each element represents a pair of cities [cityAi, cityBi], indicating a direct route from cityAi to cityBi. Your task is to find the destination city, which is the city without any outgoing path to another city.

Leetcode 1438: Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit

Given an array of integers nums and a positive integer limit, determine the length of the longest subarray where the absolute difference between the minimum and maximum elements is less than or equal to limit.

Leetcode 1441: Build an Array With Stack Operations

You are given a strictly increasing integer array target and an integer n. Starting with an empty stack, you can perform two operations: ‘Push’ to add an integer to the stack and ‘Pop’ to remove the top element from the stack. A stream of integers from 1 to n is provided. Use the stack operations to build the stack so that it contains the elements of target in order (from bottom to top). Return the sequence of operations required. Stop processing once the stack equals the target array.

Leetcode 1442: Count Triplets That Can Form Two Arrays of Equal XOR

You are given an array of integers arr. We want to find the number of triplets (i, j, k) where 0 <= i < j <= k < arr.length, such that the bitwise XOR of elements between indices i and j-1 (inclusive) equals the bitwise XOR of elements between indices j and k (inclusive).

Leetcode 1452: People Whose List of Favorite Companies Is Not a Subset of Another List

Given an array of lists where favoriteCompanies[i] represents the favorite companies of the i-th person, find the indices of people whose favorite company lists are not subsets of any other person’s list. Return these indices in increasing order.

Leetcode 1464: Maximum Product of Two Elements in an Array

Given an array of integers, you need to find two distinct elements and calculate the product of their decremented values. Specifically, you are tasked with returning the maximum value of (nums[i] - 1) * (nums[j] - 1) for two different indices i and j in the array.