All Posts
Leetcode 746: Min Cost Climbing Stairs
You are climbing a staircase with a cost associated with each step. You can either start at the first or second step. At each step, you can either move one step or skip one step. Find the minimum cost to reach the top of the staircase.
Leetcode 762: Prime Number of Set Bits in Binary Representation
Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation. The number of set bits in a number is the count of 1’s when the number is represented in binary. A prime number is a number greater than 1 that is divisible only by 1 and itself.
Leetcode 824: Goat Latin
You are given a sentence with words separated by spaces. Each word consists of only lowercase and uppercase letters. Your task is to convert the sentence into a new language called ‘Goat Latin’ by following the rules below:
- If a word begins with a vowel (‘a’, ’e’, ‘i’, ‘o’, or ‘u’), append ‘ma’ to the end of the word.
- If a word begins with a consonant, remove the first letter, move it to the end, and add ‘ma’.
- Add one letter ‘a’ to the end of each word depending on its position in the sentence (1st word gets ‘a’, 2nd gets ‘aa’, 3rd gets ‘aaa’, etc.).
Return the final sentence in Goat Latin.