Skip to content
the poor coder

Home / Topics / #leetcode

#leetcode

131 posts · page 4 of 7
2021

Leetcode - Buddy Strings Solution

Given two strings a and b, return true if you can swap two letters in a so the result is equal to b, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and…

leetcodestring2 min read
2021

Leetcode - Flipping an Image Solution

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]…

leetcodearray2 min read
2021

Leetcode - Goat Latin Solution

A sentence S is given, composed 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.)…

leetcodestring1 min read
2021

Leetcode - Most Common Word Solution

Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and that the answer is unique…

leetcodestring2 min read
2021

Leetcode - Unique Morse Code Words Solution

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…

leetcodestring1 min read
2021

Leetcode - Custom Sort String Solution

S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We want to permute the characters of T so that they match the order that S was…

leetcodestring1 min read
2021

Leetcode - Jewels and Stones Solution

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…

2021

Leetcode - Asteroid Collision Solution

We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning…

leetcodestack2 min read
2021

Leetcode - Self Dividing Numbers Solution

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. Also, a self-dividing number is not…

leetcodeMath1 min read
2021

Leetcode - Baseball Game Solution

You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds' scores. At the beginning of the game, you start with an empty…

leetcodestack3 min read
2021

Leetcode - Detect Capital Solution

We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only the first…

leetcodestring1 min read
ESC