Leetcode solutions MLP Feature Image

[Solved] An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated – we cannot choose to leave it alone.

Question An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated – we cannot choose to leave it alone. A number is valid if each digit remains a digit after rotation. For example: 0, 1, and 8 rotate to themselves, 2 and 5 rotate to each […]

[Solved] An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated – we cannot choose to leave it alone. Read More »

Leetcode solutions MLP Feature Image

[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.

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”] Example 2: Input: s = “3z4” Output: [“3z4″,”3Z4”] Constraints: 1 <= s.length <= 12 s consists

[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. Read More »

Leetcode solutions MLP Feature Image

[Solved] You’re given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels.

Question You’re given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters are case sensitive, so “a” is considered a different type of stone from “A”. Example 1: Input: jewels

[Solved] You’re given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Read More »

Leetcode solutions MLP Feature Image

[Solved] Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.

Question Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements. Example 1: Input: matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]] Output: true Explanation: In the above grid, the diagonals are: “[9]”, “[5, 5]”, “[1, 1, 1]”, “[2, 2, 2]”, “[3, 3]”, “[4]”. In each diagonal

[Solved] Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements. Read More »

Leetcode solutions MLP Feature Image

[Solved] You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1.

Question You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1. Return the minimum cost to reach the top of the floor. Example 1: Input: cost =

[Solved] You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1. Read More »

Leetcode solutions MLP Feature Image

[Solved] Given a characters array letters that is sorted in non-decreasing order and a character target, return the smallest character in the array that is larger than target.

Question Given a characters array letters that is sorted in non-decreasing order and a character target, return the smallest character in the array that is larger than target. Note that the letters wrap around. For example, if target == ‘z’ and letters == [‘a’, ‘b’], the answer is ‘a’. Example 1: Input: letters = [“c”,”f”,”j”], target = “a” Output: “c” Example 2: Input: letters = [“c”,”f”,”j”], target

[Solved] Given a characters array letters that is sorted in non-decreasing order and a character target, return the smallest character in the array that is larger than target. Read More »

Leetcode solutions MLP Feature Image

[Solved] Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature.

Question Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead. Example 1: Input: temperatures = [73,74,75,71,69,72,76,73] Output: [1,1,4,2,1,1,0,0] Example 2: Input: temperatures = [30,40,50,60]

[Solved] Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. Read More »

Leetcode solutions MLP Feature Image

[Solved] A self-dividing number is a number that is divisible by every digit it contains.

Question A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. A self-dividing number is not allowed to contain the digit zero. Given two integers left and right, return a list of all the self-dividing numbers in the range [left, right]. Example 1: Input: left

[Solved] A self-dividing number is a number that is divisible by every digit it contains. Read More »

Leetcode solutions MLP Feature Image

[Solved] Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

Question Given a string s, return the string after replacing every uppercase letter with the same lowercase letter. Example 1: Input: s = “Hello” Output: “hello” Example 2: Input: s = “here” Output: “here” Example 3: Input: s = “LOVELY” Output: “lovely” Constraints: 1 <= s.length <= 100 s consists of printable ASCII characters. Python Solution

[Solved] Given a string s, return the string after replacing every uppercase letter with the same lowercase letter. Read More »

Leetcode solutions MLP Feature Image

[Solved] Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

Question Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [-1,0,3,5,9,12], target = 9 Output: 4 Explanation: 9 exists in nums and its index is 4

[Solved] Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. Read More »

Scroll to Top