All Posts

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.

Leetcode 1480: Running Sum of 1d Array

You are given an array of integers nums. Your task is to calculate the running sum of the array, where each element at index i represents the sum of all elements from index 0 to index i in the original array.

Leetcode 1491: Average Salary Excluding the Minimum and Maximum Salary

You are given an array salary where each element represents the salary of an employee. The salaries are all unique. Return the average salary of the employees, excluding the minimum and maximum salary. Your answer should be correct to an absolute error of no more than 10^-5.

Leetcode 1496: Path Crossing

You are given a string path where each character represents a movement direction (‘N’ for north, ‘S’ for south, ‘E’ for east, ‘W’ for west). Starting from the origin (0, 0), follow the path and check if you cross your own path at any point, meaning visiting a location more than once. Return true if the path crosses itself, and false otherwise.

Leetcode 1502: Can Make Arithmetic Progression From Sequence

You are given an array of integers. Your task is to determine if the array can be rearranged to form an arithmetic progression. The array can be rearranged in any order, and the common difference between consecutive elements should be the same.

Leetcode 1512: Number of Good Pairs

You are given an array of integers. A pair (i, j) is called a good pair if nums[i] == nums[j] and i < j. Your task is to find the number of good pairs in the array.