0%

Paint House – LeetCode 256

Problem

Description

There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

The cost of painting each house with a certain color is represented by a n x 3 cost matrix. For example, costs[0][0] is the cost of painting house 0 with color red; costs[1][2] is the cost of painting house 1 with color green, and so on… Find the minimum cost to paint all houses.

Read more »

Meeting Rooms – LeetCode 252

Problem

Description

Given an array of meeting time intervals consisting of start and end times

[[s1,e1],[s2,e2],…] (si < ei), determine if a person could attend all meetings.

Read more »

Strobogrammatic Number – LeetCode 246

Problem

Description

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

Write a function to determine if a number is strobogrammatic. The number is represented as a string.

Read more »

Shortest Word Distance – LeetCode 243

Problem

Description

Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

Read more »

Valid Anagram – LeetCode 242

Problem

Description

Given two strings s and t, write a function to determine if t is an anagram of s.

Read more »

Delete Node in a Linked List – LeetCode 237

Problem

Description

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.

Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after calling your function.

Read more »

Palindrome Linked List – LeetCode 234

Problem

Description

Given a singly linked list, determine if it is a palindrome.

Read more »

Implement Queue using Stacks – LeetCode 232

Problem

Description

Implement the following operations of a queue using stacks.

  • push(x) – Push element x to the back of queue.

  • pop() – Removes the element from in front of queue.

  • peek() – Get the front element.

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

Read more »

Power of Two – LeetCode 231

Problem

Description

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

Read more »