开发者

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

开发者 https://www.devze.com 2023-02-28 12:18 出处:网络
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 bas

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

精彩评论

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