All Posts

Leetcode 670: Maximum Swap

You are given an integer num, and you can swap two digits at most once to get the largest possible number. Return the maximum number that can be obtained after performing the swap.

Leetcode 672: Bulb Switcher II

You are in a room with n bulbs, all initially turned on. There are four buttons on the wall, each with a different functionality: flip all bulbs, flip even-numbered bulbs, flip odd-numbered bulbs, and flip bulbs with labels j = 3k + 1. You need to make exactly presses presses. For each press, you can choose any button. Return the number of distinct possible configurations of the bulbs after performing all the presses.

Leetcode 673: Number of Longest Increasing Subsequence

Given an integer array nums, return the number of distinct longest increasing subsequences.

Leetcode 676: Implement Magic Dictionary

Design a data structure that supports searching for words that can be matched by changing exactly one character.

Leetcode 677: Map Sum Pairs

Design a map-like data structure that supports key-value insertion and sum queries for keys starting with a specific prefix.

Leetcode 678: Valid Parenthesis String

Given a string consisting of ‘(’, ‘)’, and ‘’, determine if the string is valid according to the following rules. ‘’ can be treated as a left parenthesis, a right parenthesis, or an empty string.