开发者

Efficient Method to Find the Lexographic Min of a Range of Integers

Given two positive integers, say M and N, with M < N, what is the most efficient algorithm to find the minimum in lexicographical order of the strings of the integers from M to N represented in base ten ASCII without leading zeros? For example, for [200, 10890], the answer is '1000', 开发者_运维技巧for [298, 900], the answer is '298'.


Efficient Method to Find the Lexographic Min of a Range of Integers


I think you're probably right in your intuition that there's a constant-time algorithm for this. You'd first find the smallest first digit, then the smallest second digit, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜