All Posts

Leetcode 2497: Maximum Star Sum of a Graph

Given a graph with n nodes, each node having a value, and a list of edges connecting the nodes, your task is to determine the maximum star sum that can be obtained. A star graph is a subgraph where all edges are connected to a central node. The star sum is the sum of the values of the central node and the nodes connected by edges to it. You are allowed to include at most k edges in the star graph.

Leetcode 2498: Frog Jump II

A frog starts on the first stone in a river and wants to jump to the last stone and then return to the first stone. The frog can jump to any stone at most once. The cost of a jump is defined as the absolute difference between the positions of two stones. The frog must choose a path that minimizes the maximum jump length during the entire journey. Return the minimum cost of the path where the cost is defined as the maximum length of any jump.

Leetcode 2501: Longest Square Streak in an Array

You are given an integer array nums. A subsequence of nums is called a square streak if its length is at least 2, and after sorting the subsequence, each element (except the first one) is the square of the previous number. Return the length of the longest square streak in nums, or -1 if no square streak exists.

Leetcode 2502: Design Memory Allocator

Design a memory allocator class with functions to allocate and free blocks of memory. The allocator should efficiently handle consecutive memory requests and be able to free blocks based on their identifiers.

Leetcode 2507: Smallest Value After Replacing With Sum of Prime Factors

You are given a positive integer n. The task is to repeatedly replace n with the sum of its prime factors, and continue this process until n reaches a value that cannot be reduced further. The process stops when the sum of the prime factors is equal to the current value of n. Return the smallest value n will eventually become.

Leetcode 2512: Reward Top K Students

You are given two lists of words: one representing positive feedback and the other representing negative feedback. Each feedback word affects a student’s points: a positive word adds 3 points, while a negative word subtracts 1 point. For each feedback report, which is associated with a student, calculate the total score by counting the occurrences of positive and negative words. After evaluating all reports, return the top k students based on their total points. In case of a tie in points, the student with the lower ID should rank higher.