0%

Intersection of Two Arrays – LeetCode 349

Problem

Description

Given two arrays, write a function to compute their intersection.

Read more »

Moving Average from Data Stream – LeetCode 346

Problem

Description

Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.

Read more »

Reverse Vowels of a String – LeetCode 345

Problem

Description

Write a function that takes a string as input and reverse only the vowels of a string.

Read more »

Reverse String – LeetCode 344

Problem

Description

Write a function that takes a string as input and returns the string reversed.

Read more »

Power of Four – LeetCode 342

Problem

Description

Given an integer (signed 32 bits), write a function to check whether it is a power of 4.

Read more »

Nested List Weight Sum – LeetCode 339

Problem

Description

Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

Each element is either an integer, or a list – whose elements may also be integers or other lists.

Read more »

Power of Three – LeetCode 326

Problem

Description

Given an integer, write a function to determine if it is a power of three.

Read more »

Range Sum Query - Immutable – LeetCode 303

Problem

Description

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.

Read more »

Flip Game – LeetCode 293

Problem

Description

You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive “++” into “–”. The game ends when a person can no longer make a move and therefore the other person will be the winner.

Write a function to compute all possible states of the string after one valid move.

Read more »

Nim Game – LeetCode 292

Problem

Description

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.

Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.

For example, if there are 4 stones in the heap, then you will never win the game: no matter 1, 2, or 3 stones you remove, the last stone will always be removed by your friend.

Read more »