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

Блог пользователя gg_ez

Автор gg_ez, история, 2 года назад, По-английски

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.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится