Bold Words in String LeetCode Solution

Problem Statement Bold Words in String LeetCode Solution – Given an array of keywords words and a string s, make all appearances of all keywords words[i] in s bold. Any letters between <b> and </b> tags become bold. Return s after adding the bold tags. The returned string should use the least number of tags possible, and the tags should form a …

Read more

Strobogrammatic Number LeetCode Solution

Problem Statement Strobogrammatic Number LeetCode Solution – Given a string num which represents an integer, return true if num is a strobogrammatic number. A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Example Test Case 1: Input: num =  “69” Output: true Test Case 2: Input: num =  “692” Output: false Explanation …

Read more

Shortest Word Distance Leetcode Solution

Problem Statement The Shortest Word Distance LeetCode Solution – says that you’re given an array of strings and two different words. We need to return the shortest distance between these two words that appear in the input string. Example: Input: wordsDict = [“practice”, “makes”, “perfect”, “coding”, “makes”], word1 = “coding”, word2 = “practice” Output: 3 Explanation: Word “coding” occurs at position 4. …

Read more

Encoded String With Shortest Length LeetCode Solution

Problem Statement Encoded String With Shortest Length LeetCode Solution – Given a string s, encode the string such that its encoded length is the shortest. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. k should be a positive integer. If an encoding process does not make the …

Read more

Largest Submatrix With Rearrangements LeetCode Solution

Problem Statement Largest Submatrix With Rearrangements LeetCode Solution – You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order. Return the area of the largest submatrix within matrix where every element of the submatrix is 1 after reordering the columns optimally. Input: matrix = [[0,0,1],[1,1,1],[1,0,1]] Output: 4 …

Read more

Translate »