All Posts
Leetcode 1668: Maximum Repeating Substring
You are given two strings: sequence
and word
. A string word
is considered ‘k-repeating’ in sequence
if word
concatenated k
times forms a substring of sequence
. The task is to return the maximum value of k
such that word
repeated k
times appears as a substring in sequence
. If no such substring exists, return 0.
Leetcode 1690: Stone Game VII
Alice and Bob are playing a game with a row of n
stones. On each player’s turn, they can remove the leftmost or the rightmost stone, and their score is the sum of the remaining stones. Alice tries to maximize the score difference, while Bob aims to minimize it. Calculate the score difference between Alice and Bob when both play optimally.
Leetcode 1696: Jump Game VI
You are given a 0-indexed integer array ’nums’ and an integer ‘k’. You start at index 0 and can jump up to ‘k’ steps forward at a time. Your task is to find the maximum sum of elements you can get by jumping to the last index, visiting subarrays of unique elements.
Leetcode 1749: Maximum Absolute Sum of Any Subarray
Given an array of integers nums
, your task is to find the maximum absolute sum of any subarray. The absolute sum of a subarray is the absolute value of the sum of its elements.
Leetcode 1774: Closest Dessert Cost
You are planning to make a custom dessert by choosing an ice cream base and toppings. The dessert must follow these rules: You must select one ice cream base. You can add one or more types of toppings, or choose to skip toppings. You can add at most two of each topping type. You are given an array representing the base costs and topping costs. The goal is to create a dessert where the total cost is as close as possible to the target price. If there are multiple dessert combinations that meet the target price, return the lower cost.
Leetcode 1786: Number of Restricted Paths From First to Last Node
You are given a connected, undirected, weighted graph with n nodes, labeled from 1 to n. An array ’edges’ represents the edges in the graph where each element edges[i] = [ui, vi, weighti] indicates that there is an edge between nodes ui and vi with a weight of weighti. A path from node start to node end is a sequence of nodes [z0, z1, …, zk] such that z0 = start, zk = end, and there is an edge between zi and zi+1 for each 0 <= i <= k-1.
The distance of a path is the sum of the weights of the edges along the path. A restricted path is a path where the distance from node ’n’ to node zi is strictly greater than the distance from node ’n’ to node zi+1 for each 0 <= i <= k-1.
You need to return the number of restricted paths from node 1 to node n, modulo 10^9 + 7.