Category Leetcode Solutions

[Solved] Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed.

Leetcode solutions MLP Feature Image

Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. For example, flipping [1,1,0] horizontally results in [0,1,1]. To invert an image means that…

[Solved] You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to “Goat Latin” (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows:

Leetcode solutions MLP Feature Image

Question You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to “Goat Latin” (a made-up language similar to Pig Latin.) The rules…

[Solved] Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest occurrence of character c in s.

Leetcode solutions MLP Feature Image

Question Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest occurrence of character c in s. The distance between two indices i and j is abs(i – j), where abs is the absolute value function. Example 1: Input: s = “loveleetcode”, c = “e” Output: [3,2,1,0,1,0,0,1,2,2,1,0]…

[Solved] Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed. A subtree of a node node is node plus every node that is a descendant of node.

Leetcode solutions MLP Feature Image

Question Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed. A subtree of a node node is node plus every node that is a descendant of node. Example 1: Input: root = [1,null,0,0,1] Output:…

[Solved] A website domain “discuss.leetcode.com” consists of various subdomains. At the top level, we have “com”, at the next level, we have “leetcode.com” and at the lowest level, “discuss.leetcode.com”. When we visit a domain like “discuss.leetcode.com”, we will also visit the parent domains “leetcode.com” and “com” implicitly.

Leetcode solutions MLP Feature Image

Question A website domain “discuss.leetcode.com” consists of various subdomains. At the top level, we have “com”, at the next level, we have “leetcode.com” and at the lowest level, “discuss.leetcode.com”. When we visit a domain like “discuss.leetcode.com”, we will also visit the parent domains “leetcode.com” and “com” implicitly. A count-paired domain is a domain…

[Solved] You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of ‘a’, widths[1] is the width of ‘b’, and so on.

Leetcode solutions MLP Feature Image

Question You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of ‘a’, widths[1] is the width of ‘b’, and so on. You are trying to write s across several lines, where each line is no…

[Solved] International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: ‘a’ maps to “.-“, ‘b’ maps to “-…”,

Leetcode solutions MLP Feature Image

Question International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: ‘a’ maps to “.-“, ‘b’ maps to “-…”, ‘c’ maps to “-.-.”, and so on. For convenience, the full table for the 26 letters of the…

[Solved] Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. Return the output in any order.

Leetcode solutions MLP Feature Image

Question Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. Return the output in any order. Example 1: Input: s = “a1b2” Output: [“a1b2″,”a1B2″,”A1b2″,”A1B2”]…