Factory is a design pattern in common usage. Please implement a ToyFactory which can generate proper toy based on the given type.
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.
Give an integer
n, write a function
fibonacci(n) that finds the n-th Fibonacci’s number.
Given a singly linked list of integers and a target value, remove all instances of the target from the list.
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.
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 given sorted integer array A and B into a new sorted integer array.
Write a function that add two numbers
B without using any arithmetic operators (
÷) and only use bit operators.
Write an algorithm which computes the number of trailing zeros in n factorial in O(log n) time.
i = [1 ... n], print
i, but if
i is divisible by 3, print
i is divisible by
i is divisible by both