All Posts

Leetcode 1784: Check if Binary String Has at Most One Segment of Ones

Given a binary string s without leading zeros, return true if the string contains at most one contiguous block of 1s. Otherwise, return false.

Leetcode 1790: Check if One String Swap Can Make Strings Equal

You are given two strings, s1 and s2, of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices. Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings. Otherwise, return false.

Leetcode 1796: Second Largest Digit in a String

You are given an alphanumeric string ’s’, which consists of lowercase English letters and digits. Your task is to find the second largest numerical digit in ’s’. If there is no second largest digit, return -1.

Leetcode 1805: Number of Different Integers in a String

You are given a string word consisting of digits and lowercase English letters. Replace every non-digit character with a space and count how many distinct integers are formed after the replacement.

Leetcode 1807: Evaluate the Bracket Pairs of a String

You are given a string s containing several bracket pairs with non-empty keys. You are also provided a 2D array knowledge where each element is a key-value pair. Your task is to evaluate the string by replacing the keys inside the bracket pairs with their corresponding values. If a key is unknown, replace it with a question mark ?.

Leetcode 1812: Determine Color of a Chessboard Square

You are given the coordinates of a square on a chessboard. The coordinate is represented as a string where the first character is a letter representing the column (‘a’ to ‘h’) and the second character is a number representing the row (‘1’ to ‘8’). Determine if the square is white or black. A square is white if the sum of its row and column is even, and black if it is odd.