Week2 (Mar 18)

264. Ugly Number II

Question

An ugly number is a positive integer whose prime factors are limited to

2,
3
, and
5
.

Given an integer

n, return the
nth
ugly number.

Hand in homework before Saturday.

461. Hamming Distance

Question

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

Given two integers

x and
y
, return the Hamming distance between them.

Hand in homework before Saturday.

Roger的作業
Wen的作業
xander的作業
woody的作業
Continue filling by yourself

66. Plus One

Question

You are given a large integer represented as an integer array

digits, where each
digits[i]
is the
ith
digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading
0
's
.

Increment the large integer by one and return the resulting array of digits.

Hand in homework before Saturday.

463. Island Perimeter

Question

You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water.

Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells).

The island doesn't have "lakes", meaning the water inside isn't connected to the water around the island. One cell is a square with side length 1. The grid is rectangular, width and height don't exceed 100. Determine the perimeter of the island.

Hand in homework before saturday.