Colorful Number
Function Name: isColorful
Description
A colorful number is a number where the product of every digit of a contiguous subset of its digits is different. For example, 263 is a colorful number because (2), (6), (3), (2*6), (6*3), (2*6*3) are all different. However, 236 is not colorful since (2*3) and (6) are both equal to 6.
Write a function `isColorful` that takes a positive integer and returns a boolean indicating whether the number is colorful or not.
Requirements
- The function should take a single integer as its parameter.
- The function should not use any external libraries or modules.
- The function should handle input up to 32-bits (handle numbers up to 2,147,483,647).
- Consider optimizing the solution to handle repeated products efficiently.
Examples
isColorful(263) should return true.isColorful(236) should return false.isColorful(1) should return true.
Links
Circular Queue Implementation
Thu Aug 08 2024
Implement a Circular Queue data structure with a fixed size using only primitive data structures (arrays, not language-specific collections). The CircularQueue class should support the following operations: enqueue, dequeue, peek, and isEmpty.The enqueue operation adds an item to the back of the queue, the dequeue operation removes an item from the front of the queue, peek returns the front element without removing it, and isEmpty indicates whether the queue is empty.If the queue is full and an enqueue operation is attempted, the function should return false or indicate that the queue is full. When dequeue is called on an empty queue, it should return null or an appropriate indicator of emptiness.
Matrix Spiral Copy
Sat Aug 10 2024
Create a function that takes a 2D array (matrix) as a parameter and returns a list of its elements in spiral order.Spiral order starts at the top-left corner of the 2D array, goes to the right, and proceeds in a spiral pattern all the way until every element has been visited.