All Posts

Leetcode 70: Climbing Stairs

You need to climb a ladder with n steps to reach the top. Each time, you can either climb 1 step or 2 steps. Find the number of distinct ways to climb to the top.

Leetcode 139: Word Break

Given a string s and a dictionary of words wordDict, return true if s can be segmented into a space-separated sequence of one or more words from the dictionary. The same word in the dictionary can be reused multiple times.

Leetcode 397: Integer Replacement

Given a positive integer n, you can perform one of the following operations: If n is even, divide n by 2. If n is odd, you can either add 1 to n or subtract 1 from n. Your task is to return the minimum number of operations required to reduce n to 1.

Leetcode 509: Fibonacci Number

The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, starting from 0 and 1. Given an integer n, return the nth Fibonacci number.

Leetcode 638: Shopping Offers

In a store, there are n items available for sale, each with a given price. You are also given a list of special offers where you can buy multiple items at a discounted price. Your task is to determine the minimum total price to purchase the required quantities of each item, while utilizing the special offers optimally. You can use any offer as many times as you like, but cannot buy more items than you need.

Leetcode 698: Partition to K Equal Sum Subsets

Given an integer array nums and an integer k, your task is to determine if it is possible to divide this array into k non-empty subsets such that each subset has an equal sum.