All Posts

Leetcode 2395: Find Subarrays With Equal Sum

You are given a 0-indexed integer array nums. Your task is to determine if there are two subarrays of length 2 that have the same sum, but these subarrays must begin at different indices in the array. A subarray is defined as a contiguous sequence of elements within the array.

Leetcode 2399: Check Distances Between Same Letters

You are given a string s consisting of lowercase English letters where each letter appears exactly twice. You are also given an array distance of length 26, where each element represents the number of characters between the two occurrences of the corresponding letter (0-indexed, ‘a’ corresponds to index 0, ‘b’ to index 1, etc.). Your task is to determine if the string s is a ‘well-spaced’ string. A string is well-spaced if, for each letter in s, the number of characters between its two occurrences matches the corresponding value in the distance array.

Leetcode 2404: Most Frequent Even Element

You are given an integer array nums. Your task is to return the most frequent even element in the array. If there is a tie (i.e., multiple even elements appear the most number of times), return the smallest one. If there is no even element, return -1.

Leetcode 2409: Count Days Spent Together

Alice and Bob are traveling to Rome for separate business meetings. You are given four strings representing their travel dates: arriveAlice, leaveAlice, arriveBob, and leaveBob. Each string follows the format ‘MM-DD’, which represents the month and day of their respective travel dates. Alice will be in Rome from ‘arriveAlice’ to ’leaveAlice’, while Bob will be in the city from ‘arriveBob’ to ’leaveBob’. Your task is to calculate how many days they will both be in Rome together.

Leetcode 2413: Smallest Even Multiple

Given a positive integer ’n’, return the smallest positive integer that is a multiple of both 2 and ’n'.

Leetcode 2418: Sort the People

Given two arrays, one containing the names and the other containing the corresponding heights of people, return the names sorted in descending order by their heights.