Toy Factory

Factory is a design pattern in common usage. Please implement a ToyFactory which can generate proper toy based on the given type.

Move Zeroes

Given an array nums, write a function to move all 0’s to the end of the array. The operation should be done in-place without making a copy of the array and the non-zero elements should stay in the original relative order.

Fibonacci

Give an integer n, write a function fibonacci(n) that finds the n-th Fibonacci’s number.

Remove Linked List Elements

Given a singly linked list of integers and a target value, remove all instances of the target from the list.

Intersection of Two Arrays II

Given two arrays, write a function to compute their intersection. Each element in the result array can have duplicates, but the duplicates should only appear as many times as in both arrays. The result array can be in any order.

Intersection of Two Arrays

Given two arrays, representing sets, write a function to compute the intersection of these two sets. Each element in the result must be unique and the result can be in any order.

Merge Two Sorted Arrays

Merge two given sorted integer array A and B into a new sorted integer array.

A + B Problem

Write a function that add two numbers A and B without using any arithmetic operators (+, -, ×, ÷) and only use bit operators.

Trailing Zeros

Write an algorithm which computes the number of trailing zeros in n factorial in O(log n) time.

Fizz Buzz

For i = [1 ... n], print i, but if i is divisible by 3, print "fizz"; if i is divisible by 5, print "buzz"; if i is divisible by both 3 and 5, print "fizz buzz".