Skip to content
the poor coder

Home / Topics / #leetcode

#leetcode

131 posts · page 5 of 7
2021

Leetcode - Ransom Note Solution

Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will…

leetcodestring1 min read
2021

Leetcode - Design Twitter Solution

Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user's news feed. Implement the Twitter class: Twitter() Initializes…

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…

ESC