public class Solution { public IList<int> SelfDividingNumbers(int left, int right) { var list = new List<int>(); for (var i = left; i <= right; ++i) { for (var n = i; n > 0; n /= 10) { var toDivide = n % 10; if (toDivide == 0 || i % toDivide != 0) { goto goNextNumber; } } list.Add(i); goNextNumber:; } return list; } }Source: https://leetcode.com/problems/self-dividing-numbers/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Saturday, March 20, 2021
Leetcode Everyday: 728. Self Dividing Numbers. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment