Category Leetcode Solutions

[Solved] There is an m x n matrix that is initialized to all 0’s. There is also a 2D array indices where each indices[i] = [ri, ci] represents a 0-indexed location to perform some increment operations on the matrix.

Leetcode solutions MLP Feature Image

Question There is an m x n matrix that is initialized to all 0‘s. There is also a 2D array indices where each indices[i] = [ri, ci] represents a 0-indexed location to perform some increment operations on the matrix. For each location indices[i], do both of the following: Increment all the cells on row ri.…

[Solved] Given a callable function f(x, y) with a hidden formula and a value z, reverse engineer the formula and return all positive integer pairs x and y where f(x,y) == z. You may return the pairs in any order.

Leetcode solutions MLP Feature Image

Question Given a callable function f(x, y) with a hidden formula and a value z, reverse engineer the formula and return all positive integer pairs x and y where f(x,y) == z. You may return the pairs in any order. While the exact formula is hidden, the function is monotonically…

[Solved] Balanced strings are those that have an equal quantity of ‘L’ and ‘R’ characters. Given a balanced string s, split it into some number of substrings such that: Each substring is balanced.

Leetcode solutions MLP Feature Image

Question Balanced strings are those that have an equal quantity of ‘L’ and ‘R’ characters. Given a balanced string s, split it into some number of substrings such that: Each substring is balanced. Return the maximum number of balanced strings you can obtain. Example 1: Input: s = “RLRRLLRLRL” Output: 4…

[Solved] Given a string text, you want to use the characters of text to form as many instances of the word “balloon” as possible. You can use each character in text at most once. Return the maximum number of instances that can be formed.

Leetcode solutions MLP Feature Image

Question Given a string text, you want to use the characters of text to form as many instances of the word “balloon” as possible. You can use each character in text at most once. Return the maximum number of instances that can be formed. Example 1: Input:…

[Solved] Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum of all the values of nodes at level x is maximal.

Leetcode solutions MLP Feature Image

Question Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum of all the values of nodes at level x is maximal. Example 1: Input: root = [1,7,0,7,-8,null,null]…

[Solved] You are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be used once). Return the sum of lengths of all good strings in words.

Leetcode solutions MLP Feature Image

Question You are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be used once). Return the sum of lengths of all good strings in words. Example 1:…

[Solved] Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.

Leetcode solutions MLP Feature Image

Question Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of…

[Solved] Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period “.” with “[.]”.

Leetcode solutions MLP Feature Image

Question Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period “.” with “[.]”. Example 1: Input: address = “1.1.1.1” Output: “1[.]1[.]1[.]1” Example 2: Input: address = “255.100.50.0” Output: “255[.]100[.]50[.]0” Constraints: The given address is a valid IPv4…

[Solved] Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.

Leetcode solutions MLP Feature Image

Question Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of…