superReducedString-hankerrank
Steve has a string of lowercase characters in range ascii[‘a’..’z’]. He wants to reduce the string to its shortest length by doing a series of operations. In each operation he selects a pair of adjacent lowercase letters that match, and he deletes them. For instance, the string aab could be shortened to b in one operation.
Steve’s task is to delete as many characters as possible using this method and print the resulting string. If the final string is empty, print Empty String
aaabccddd → abccddd → abddd → abd
aa → Empty String
baab → bb → Empty String
superReducedString-hankerrank的更多相关文章
- [hankerrank]Counter game
https://www.hackerrank.com/contests/w8/challenges/counter-game 关键是二分查找等于或最接近的小于target的数.可以使用和mid+1判断 ...
- Largest Rectangular Area in a Histogram 最大连续面积
在HankerRank遇到一题计算柱状图连续矩形面积的问题. 举例 hist = [3, 2, 3]. 在这个柱状图里面最大可以容纳一个high = 2 length = 3的连续矩形, 其面积 = ...
随机推荐
- 201671010142 2017-2 《java第十二章学习感悟》
Swing 是一个为Java设计的GUI工具包. Swing是JAVA基础类的一部分. Swing包括了图形用户界面(GUI)器件如:文本框,按钮,分隔窗格和表. Swing提供许多比AWT更好的屏幕 ...
- python 在内网windows环境下pip三方包
我没用过Linux环境. 一般情况下,内网安装三方包,只需要在pypi找到对应python版本(2.7,3.6,...),系统位数(32位,64位)的whl包,cmd命令行cd进入相关目录,pip i ...
- JAVA----线程初级
一.认识多任务.多进程.单线程.多线程 要认识多线程就要从操作系统的原理说起. 以前古老的DOS操作系统(V 6.22)是单任务的,还没有线程的概念,系统在每次只能做一件事情.比如你在copy东西 ...
- lintcode中等题目的四道题
第一题: 第一句先创建了一个解决问题的类, 第二句声明了一个公共接口的整形链表里面有N个整形数, 第三句给链表动态初始化, 第四步判断链表里的数有没有,如果N<=0则返回结果0,否则执行Prin ...
- Git实操
使用git首先要理解工作区(working).暂存区(stage或者index).和版本库(repo区),很多命令都是和这三个概念相关的. git init 初始化git仓库,会生成默认的.git文件 ...
- js插件ztree使用
最新给公司后台写了一个配置页面,在网上搜到一个js插件ztree,记录一下使用心得. 首先说一下ztree官网,好多方法我都是从官网api上学习的,官网地址http://www.treejs.cn/v ...
- getString与optString的区别
JSONObject.getString("key"):当对象中没有key属性的时候,会抛出No value for "key"的异常: public Stri ...
- WordCount程序与测试
Github地址: https://github.com/hcy6668/wordCount PSP表格: PSP PSP阶段 预估耗时(分钟) 实际耗时(分钟) Planning 计划 60 40 ...
- 【转】forbids in-class initialization of non-const static member不能在类内初始化非const static成员
转自:forbids in-class initialization of non-const static member不能在类内初始化非const static成员 今天写程序,出现一个新错误,好 ...
- 使用spring框架,用xml方式进行bean装配出现“The fully qualified name of the bean's class, except if it serves...”
使用spring框架,用xml方式进行bean装配出现“The fully qualified name of the bean's class, except if it serves...”. 原 ...