HackerRank "Morgan and a String"
2016-04-08 03:13
417 查看
I saw the same sub-problem in LeetCode, and there exists a O(n) neat greedy solution:
Please note: '[' is the first char after 'Z'.
for _ in range(int(input())): a = input() + '[' b = input() + '[' output = "" for _ in range(len(a) + len(b) - 2): if a < b: output += a[0] a = a[1:] else: output += b[0] b = b[1:] print(output)
Please note: '[' is the first char after 'Z'.
相关文章推荐
- web安全
- 观察者设计模式
- Python—sqlalchemy
- asp 为html控件添加服务器端事件
- Django REST framework教程一:序列化
- .Net转前端开发-启航篇,如何定制博客园主题
- DrawLayout 侧滑侧栏点击穿透
- iOS版本、iPhone版本、Xcode版本比对
- 【Swift学习】Swift编程之旅(一)
- poj3468 A Simple Problem with Integers[线段树成段更新成段查询]
- 看看什么是真正的瀑布流开发
- LeetCode 257 Binary Tree Paths
- 使用ListActivity
- iOS之多线程浅谈
- HackerRank "Favorite sequence"
- Intellij Idea 设置方法模板
- 括号匹配(){}[]({[]})
- HDU 1166 敌兵布阵[线段树单点更新成段查询]
- 序列化二叉树
- 《JAVA并发编程实践》学习笔记(第三章)