All Posts

Leetcode 1816: Truncate Sentence

Given a sentence with words separated by a space, truncate the sentence to contain only the first k words. Return the truncated sentence.

Leetcode 1817: Finding the Users Active Minutes

Given the logs of users’ actions on a platform, calculate the number of users with each possible User Active Minutes (UAM) from 1 to k.

Leetcode 1818: Minimum Absolute Sum Difference

You are given two positive integer arrays nums1 and nums2 of the same length n. You are allowed to change at most one element of nums1 to any other value from nums1 to minimize the total absolute sum difference between nums1 and nums2. Return the minimum absolute sum difference after making the replacement. Since the answer may be large, return it modulo 10^9 + 7.

Leetcode 1822: Sign of the Product of an Array

You are given an integer array nums. The task is to compute the product of all the elements in the array and return the sign of the product. Implement the function signFunc(x) that returns 1 if x is positive, -1 if x is negative, and 0 if x is 0. Return signFunc(product) for the array.

Leetcode 1823: Find the Winner of the Circular Game

In this problem, there are n friends sitting in a circle. The game proceeds by counting k friends clockwise starting from the 1st friend. The last friend counted leaves the circle. This continues until only one friend remains, who is the winner. Your task is to find the winner of the game given n and k.

Leetcode 1824: Minimum Sideway Jumps

A frog is traveling on a 3-lane road, starting at point 0 on lane 2. The frog wants to reach point n, but there may be obstacles at various points on the road. The frog can either move forward on the same lane or jump to another lane if the current lane is blocked. The goal is to find the minimum number of side jumps the frog needs to take to reach point n while avoiding obstacles.