[LintCode] Nuts & Bolts Problem 螺栓螺母问题
2016-09-02 12:58
387 查看
Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping between nuts and bolts. Comparison of a nut to another nut or a bolt to another bolt is not allowed. It means nut can only be compared with bolt and bolt can only be compared with nut to see which one is bigger/smaller.
We will give you a compare function to compare nut with bolt.
Have you met this question in a real interview?
Example
Given nuts = ['ab','bc','dd','gg'], bolts = ['AB','GG', 'DD', 'BC'].
Your code should find the matching bolts and nuts.
one of the possible return:
nuts = ['ab','bc','dd','gg'], bolts = ['AB','BC','DD','GG'].
we will tell you the match compare function. If we give you another compare function.
the possible return is the following:
nuts = ['ab','bc','dd','gg'], bolts = ['BC','AA','DD','GG'].
So you must use the compare function that we give to do the sorting.
The order of the nuts or bolts does not matter. You just need to find the matching bolt for each nut.
We will give you a compare function to compare nut with bolt.
Have you met this question in a real interview?
Example
Given nuts = ['ab','bc','dd','gg'], bolts = ['AB','GG', 'DD', 'BC'].
Your code should find the matching bolts and nuts.
one of the possible return:
nuts = ['ab','bc','dd','gg'], bolts = ['AB','BC','DD','GG'].
we will tell you the match compare function. If we give you another compare function.
the possible return is the following:
nuts = ['ab','bc','dd','gg'], bolts = ['BC','AA','DD','GG'].
So you must use the compare function that we give to do the sorting.
The order of the nuts or bolts does not matter. You just need to find the matching bolt for each nut.
相关文章推荐
- Lintcode: Nuts & Bolts Problem
- lintcode-medium-Nuts & Bolts Problem
- Nuts & Bolts Problem
- Nuts & Bolts Problem
- 类加载器的相关问题(ClassLoader&&LinkageError)
- struts国际化问题"——终极解决方案
- .Net环境水晶报表在98下发布,出现"不能加载报表..."问题的解决
- 在asp.net中有关"弹出对话框"的问题
- SQL BUG集之"随机排序中的newid()问题"
- 关于C++&Java中命令行编译的问题
- VS2005 Web Application Project的一些问题
- "struts中文问题","struts国际化问题"的终极解决方案(转)
- java连接数据库==>出现问题了
- 问题点&二进制I/O函数fread(),fwrite()的使用
- "struts中文问题","struts国际化问题"的终极解决方案[转载]
- ASP.NET AJAX 1.0 Upgrade problems/升级问题
- "struts中文问题","struts国际化问题"的终极解决方案
- 对"一个非常难的查询问题(部门上下级的关系)"之解答的完善
- 面试时最经常被问到的问题(Frenquently asked interview questions)之Algorithms & Coding篇
- LEX&YACC使用问题集