0%

Implement Stack using Queues – LeetCode 225

Problem

Description

Implement the following operations of a stack using queues.

  • push(x) – Push element x onto stack.

  • pop() – Removes the element on top of the stack.

  • top() – Get the top element.

  • empty() – Return whether the stack is empty.

Read more »

Contains Duplicate II – LeetCode 219

Problem

Description

Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.

Read more »

Contains Duplicate – LeetCode 217

Problem

Description

Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.

Read more »

House Robber – LeetCode 198

Problem

Description

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

Read more »

Number of 1 Bits – LeetCode 191

Problem

Description

Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).

Read more »

Reverse Bits – LeetCode 190

Problem

Description

Reverse bits of a given 32 bits unsigned integer.

Read more »

Rotate Array – LeetCode 189

Problem

Description

Rotate an array of n elements to the right by k steps.

Read more »

Factorial Trailing Zeroes – LeetCode 172

Problem

Description

Given an integer n, return the number of trailing zeroes in n!.

Note: Your solution should be in logarithmic time complexity.

Read more »