Back to problems

Solve Digit-Square and Grid BFS Problems

Algorithm · Apple · Hard

This problem has three independent parts. Part 1: Repeated Digit-Square Mapping For a positive integer n, define one operation as computing the next integer by squaring each digit in the decimal representation of n and adding the results together. Apply this operation repeatedly. Return true if the process eventually reaches 1. Return false if the sequence enters a cycle that never contains 1. Example 1: Explanation: The sequence proceeds as 7 -> 49 -> 97 -> 130 -> 10 -> 1.…

Checking your access…