Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Find all numbers multiple of 3

Правка en1, от gg_ez, 2022-08-20 18:37:05

You are given a number n and digit d (d <= n <= 10). Your goal is to count all d-digit numbers including 0 to n that are divisible by 3.

The question was asked to me in a company interview and the only logic I gave was from backtracking by rearranging the digits and excluding the case where the left-most number is 0, but the interviewer didn't look much happy with my logic. Is there any better logic for these types of questions in general?

Thanks in advance.

Теги algorithms

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский gg_ez 2022-08-20 18:37:05 498 Initial revision (published)