#3348

Smallest Divisible Digit Product II

hard · 14.5% accepted · 57 likes · top 0%

math · string · backtracking · greedy · number theory

⊣ practice⊣ open on leetcode ↗

Description

You are given a string num which represents a positive integer, and an integer t.

A number is called zero-free if none of its digits are 0.

Return a string representing the smallest zero-free number greater than or equal to num such that the product of its digits is divisible by t. If no such number exists, return "-1".

Solution