Skip to content
the poor coder

Home / Author

Poor Man

2,994 posts
2021

Leetcode - Defanging an IP Address Solution

Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]". Example 1: Example 2: Constraints: The given address is a valid IPv4 address…

leetcodestring1 min read
2021

Leetcode - Height Checker Solution

A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected…

leetcodearray1 min read
2021

Leetcode - Reverse Only Letters Solution

Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions. Example 1: Example 2: Example 3: Note: S.length <= 100 33 <=…

leetcodestring1 min read
2021

Leetcode - Sort Array By Parity Solution

Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any answer array that satisfies this condition. Example 1: Note…

leetcodearray1 min read
2021

Leetcode - Find and Replace Pattern Solution

You have a list of words and a pattern, and you want to know which words in words matches the pattern. A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the…

leetcodestring1 min read
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
ESC