0%

Happy Number – LeetCode 202

Problem

Description

Write an algorithm to determine if a number 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, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.

Read more »

Linked List Cycle – LeetCode 141

Problem

Description

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

Follow up:
Can you solve it without using extra space?

Read more »

Single Number – LeetCode 136

Problem

Description

Given an array of integers, every element appears twice except for one. Find that single one.

Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

Read more »

Valid Palindrome – LeetCode 125

Problem

Description

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

Read more »

Best Time to Buy and Sell Stock II – LeetCode 122

Problem

Description

Say you have an array for which the $i^{th}$ element is the price of a given stock on day i.

Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).

Read more »

Best Time to Buy and Sell Stock – LeetCode 121

Problem

Description

Say you have an array for which the $i^{th}$ element is the price of a given stock on day i.

If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.

Read more »

Pascal’s Triangle II – LeetCode 119

Problem

Description

Given an index k, return the $k^{th}$ row of the Pascal’s triangle.

Read more »

Pascal’s Triangle – LeetCode 118

Problem

Description

Given numRows, generate the first numRows of Pascal’s triangle.

Read more »

Path Sum – LeetCode 112

Problem

Description

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.

Read more »

Minimum Depth of Binary Tree – LeetCode 111

Problem

Description

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.

Read more »