All Posts

Leetcode 931: Minimum Falling Path Sum

Given a square matrix of integers, your task is to find the minimum sum of any falling path through the matrix. A falling path starts at any element in the first row and chooses the next element from the row directly below it, which can be either directly below, diagonally left, or diagonally right.

Leetcode 935: Knight Dialer

A knight is on a phone pad, and it can move to adjacent numeric cells according to its unique movement pattern (an L-shape: two squares vertically and one square horizontally, or two squares horizontally and one square vertically). Given an integer n, you need to calculate how many distinct phone numbers of length n the knight can dial, starting from any numeric cell on the pad and performing n-1 valid knight jumps.

Leetcode 978: Longest Turbulent Subarray

Given an integer array arr, return the length of the largest subarray that is turbulent. A subarray is considered turbulent if the comparison sign alternates between each adjacent pair of elements.

Leetcode 983: Minimum Cost For Tickets

You are planning a series of train travels throughout the year. The days you plan to travel are given in a list of integers, where each integer represents a day of the year (from 1 to 365). You need to find the minimum cost needed to cover all the travel days using 1-day, 7-day, and 30-day passes.

Leetcode 1014: Best Sightseeing Pair

You are given an array where each element represents the value of a sightseeing spot. The distance between two sightseeing spots is the difference in their indices. The score of a pair of sightseeing spots i and j (where i < j) is calculated as values[i] + values[j] + (i - j), which includes the values of both spots and subtracts the distance between them. Your task is to find the maximum score of any pair of sightseeing spots.

Leetcode 1024: Video Stitching

You are given a set of video clips from a sporting event that lasts a specified duration in seconds. The clips may overlap and have varying lengths. The goal is to determine the minimum number of clips required to cover the entire event. If it’s impossible to cover the entire event, return -1.