Skip to content
the poor coder

Home / Author

Poor Man

2,994 posts
2021

Leetcode - Count and Say Solution

The count-and-say sequence is a sequence of digit strings defined by the recursive formula: countAndSay(1) = "1" countAndSay(n) is the way you would "say" the digit string from countAndSay(n-1), which is then converted…

leetcode1 min read
2021

Leetcode - Power of Four Solution

Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such that n == 4x. Example 1: Example 2: Example 3: Constraints: -231 <= n…

2021

Leetcode - Power of Three Solution

Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3x. Example 1: Example 2: Example 3: Example 4…

leetcodeMath1 min read
2021

Leetcode - Bulls and Cows Solution

You are playing the Bulls and Cows game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info: The…

2021

Leetcode - Word Pattern Solution

Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Example 1: Example 2: Example 3…

2021

Leetcode - Happy Number Solution

Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits. Repeat…

2021

Leetcode - Min Stack Solution

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes the stack object. void push(val) pushes the element val onto the…

2021

Leetcode - Triangle Solution

Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either…

2021

Leetcode - Pascal's Triangle II Solution

Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Example 2: Example 3…

leetcodearray1 min read
2021

Leetcode - Pascal's Triangle Solution

Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Example 2: Constraints: 1 <= numRows <= 30…

leetcodearray1 min read
2021

Leetcode - Word Search Solution

Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or…

ESC