All Posts

Leetcode 1433: Check If a String Can Break Another String

You are given two strings s1 and s2 of the same length. You need to check if some permutation of s1 can ‘break’ some permutation of s2, or vice-versa. A string x can break string y if for every character at position i, x[i] >= y[i] when sorted alphabetically.

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 1443: Minimum Time to Collect All Apples in a Tree

You are given an undirected tree with n vertices numbered from 0 to n-1. Some vertices in this tree contain apples. Each edge in the tree requires 1 second to traverse. Starting at vertex 0, determine the minimum time required to collect all apples and return to vertex 0. The tree structure is described by the array edges, where edges[i] = [ai, bi] indicates an edge between vertices ai and bi. Additionally, the array hasApple specifies whether a vertex contains an apple (true) or not (false).

Leetcode 1447: Simplified Fractions

Given an integer n, return a list of all unique simplified fractions between 0 and 1 (exclusive) where the denominator is less than or equal to n. A fraction is simplified if the greatest common divisor (GCD) of the numerator and denominator is 1. The result can be returned in any order.