[LintCode] Nuts & Bolts Problem 螺栓螺母问题
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.
[LintCode] Nuts & Bolts Problem 螺栓螺母问题的更多相关文章
- Lintcode: Nuts & Bolts Problem
Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping ...
- Lintcode399 Nuts & Bolts Problem solution 题解
[题目描述] Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one m ...
- Nuts & Bolts Problem
Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping ...
- LintCode A + B Problem
原题链接在这里:http://www.lintcode.com/en/problem/a-b-problem/ 不让用 数学运算符,就用位运算符. a的对应位 ^ b的对应位 ^ carry 就是re ...
- LintCode "Post Office Problem" !!!
* Non-intuitive state design class Solution { public: /** * @param A an integer array * @param k an ...
- [LintCode]——目录
Yet Another Source Code for LintCode Current Status : 232AC / 289ALL in Language C++, Up to date (20 ...
- lintcode算法周竞赛
------------------------------------------------------------第七周:Follow up question 1,寻找峰值 寻找峰值 描述 笔记 ...
- 7九章算法强化班全解--------Hadoop跃爷Spark
------------------------------------------------------------第七周:Follow up question 1,寻找峰值 寻找峰值 描述 笔记 ...
- (C#)算法题
1. Convert string from "AAABBCC" to "A3B2C2". 当面试者提出这个问题的时候,首先需要确认题意:譬如:字符串是不是顺序 ...
随机推荐
- text()、html() 以及 val()的区别
text() - 设置或返回所选元素的文本内容 html() - 设置或返回所选元素的内容(包括 HTML 标记) val() - 设置或返回表单字段的值 下面的例子演示如何通过 text().htm ...
- hdu3709 Balanced Number (数位dp+bfs)
Balanced Number Problem Description A balanced number is a non-negative integer that can be balanced ...
- css整理-06 表和列表
表格式化 表布局 table, display:table caption, display: table-caption thead, display: table-header-group tbo ...
- WPF VlC 实现视频的播放(1)
WPF 使用VLC实现视频的播放:网上开源代码我复制了一份: https://github.com/someonehan/Vlc.DotNet 1. 准备阶段 (I) libvlc.dll 和 l ...
- ajax乱码
ajax提交请求,参数在data上依然乱码,并且已经做了过滤转码, 其他请求没有问题,此请求有问题建议使用下述方式处理: 前端:encodeURIComponent(fileName)或者encode ...
- DELPHI与C#语法比较
1.我做了三年的.NET,也是三个月前因为项目需要转的delphi整个过渡差不多要一周到两周.正常情况两周后就能熟悉delphi.delphi可以调整开发环境的,你把他的属性和解决方案窗口调成和你用V ...
- 【CLR in c#】事件
1.事件模型建立在委托的基础上. 2,定义事件编译器会做三个动作,第一个构造具有委托类型的字段,事件发生时会通知这个列表中的委托. 第二个构造的是一个添加关注的方法+=. 第三个构造是一个注销事件关 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
- Java API 实现HBase的数据添加与过滤查询
包依赖比较麻烦,找了好久,我用的CDH5.0 现将所依赖的包的列表清单如下: public class EmployeeDao { /** * @param args */ public static ...
- Mac 显示 Finder 隐藏文件
显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏Mac隐藏文件的命令:defaults writ ...