Skip to main content

49 docs tagged with "Easy"

View All Tags

Add Binary

Given two binary strings a and b, return their sum as a binary string.

Backspace String Compare

Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character.

Best Time To Buy And Sell Stock

You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.

Binary Search

Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums...

Climbing Stairs

You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

Contains Duplicate

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

Convert 1D Array into 2D Array

You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.

Counting Bits

Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.

Find Smallest Letter Greater Than Target

Return the smallest character in letters that is lexicographically greater than target. If such a character does not exist, return the first character in letters.

First Bad Version

Implement a function to find the first bad version. You should minimize the number of calls to the API.

Flood Fill

An image is represented by an m x n integer grid image where image[i][j] represents the pixel value of the image.

Implement Queue using Stacks

Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue...

Linked List Cycle

Given head, the head of a linked list, determine if the linked list has a cycle in it.

Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.

Longest Palindrome

Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.

Merge Two Binary Trees

Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree.

Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

Missing Number

Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.

Move Zeroes

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.

Number of 1 Bits

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

Palindrome Linked List

Given the head of a singly linked list, return true if it is a palindrome or false otherwise.

Palindrome Number

Given an integer x, return true if x is a palindrome, and false otherwise.

Path Sum

Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum.

Range Query Sum Immutable

Calculate the sum of the elements of nums between indices left and right inclusive where left <= right.

Ransome Note

Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.

Remove Linked List Elements

Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.

Reverse Bits

Reverse bits of a given 32 bits unsigned integer.

Reverse Linked List

Given the head of a singly linked list, reverse the list, and return the reversed list.

Same Tree

Given the roots of two binary trees p and q, write a function to check if they are the same or not.

Single Number

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

Squares of a Sorted Array

Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

Subtree of Another Tree

Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.

Symmetric Tree

Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).

Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

Valid Anagram

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

Valid Palindrome

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.

Valid Parentheses

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.