Created
August 9, 2021 07:10
-
-
Save hoozecn/39e1867057010ca96f6c503c91b604b6 to your computer and use it in GitHub Desktop.
螺帽螺母
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
有N对匹配的螺母(nut)和螺栓(bolt),被拆分开后被分成了螺母和螺栓各一堆,并且打乱。并且有如下的假设个规则: | |
每对螺母和螺栓的尺寸都不一样,并且不能直接量尺寸 | |
螺母和螺母之间不能比大小 | |
螺栓和螺栓之间不能比大小 | |
螺母和螺栓可以做比较并且得出:匹配,螺母太小,螺母太大三种结果 | |
设计一个算法最快时间匹配螺母和螺栓。 | |
提供的class | |
class Nut {} // 螺母 | |
class Bolt {} // 螺栓 | |
提供的可用函数 | |
int match(Nut n, Bolt b) // 当return 0为匹配;return 1为nut比bolt大; return -1为nut 比 bolt 小 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment