All Posts

Leetcode 2799: Count Complete Subarrays in an Array

You are given an array ’nums’ consisting of positive integers. A subarray is called complete if the number of distinct elements in the subarray is equal to the number of distinct elements in the entire array. Return the total number of complete subarrays.

Leetcode 2800: Shortest String That Contains Three Strings

Given three strings ‘a’, ‘b’, and ‘c’, find a string that contains all three of these strings as substrings and has the minimum possible length. If there are multiple such strings, return the lexicographically smallest one.

Leetcode 2807: Insert Greatest Common Divisors in Linked List

You are given the head of a linked list, where each node contains an integer. For each pair of adjacent nodes, insert a new node with a value equal to the greatest common divisor (GCD) of the two nodes. Return the modified linked list after performing this operation.

Leetcode 2808: Minimum Seconds to Equalize a Circular Array

You are given a 0-indexed array nums containing n integers. At each second, replace every nums[i] with either nums[i], nums[(i-1+n)%n], or nums[(i+1)%n]. Return the minimum number of seconds required to make all elements in the array equal.

Leetcode 2811: Check if it is Possible to Split Array

You are given an array nums and an integer m. You need to determine if it’s possible to split the array into n subarrays of size 1, following the rules that each subarray must either have length 1 or have a sum of elements greater than or equal to m.

Leetcode 2812: Find the Safest Path in a Grid

You are given a square grid of size n x n, where each cell contains either a thief (represented by 1) or is empty (represented by 0). You start at the top-left corner of the grid and must find the maximum safeness factor for a path to the bottom-right corner. The safeness factor is defined as the minimum Manhattan distance from any cell in the path to the nearest thief.