Basic Calculator II (Min Tree)

2016-08-01
阅读 4 分钟
2.3k
题目:Basic Calculator的升级版,这次要求加括号了。分析:在Basic Calculator I里,做法是用stack存储整数,如果是乘除操作就先执行运算再存储,如果是加减的话就直接存储数据。这么做的实质其实是统一运算符的优先级——把优先级高的操作先执行掉,stack里存的数据都是优先级统一的加减操作,于是最后直接累加就可以了...

Basic Calculator

2016-08-01
阅读 2 分钟
1.8k
题目:实现一个计算器的基本功能,整数的加减乘除操作。遵循运算符优先次序,但是不要求加括号。分析:(1)使用Stack存储数据,这样做的好处是在乘除操作的时候可以取出最近存进的整数,乘除操作完再把结果压进Stack;(2)字符串处理的时候使用Character.isDigit()方法来判断,这里容易犯错的是,操作符的判断比数字判断先...

Design CML-TAB

2016-07-31
阅读 4 分钟
1.9k
设计功能:(1)返回可能命令集:如果当前字符串是若干个命令字符串的最长共同前缀,返回可能的命令字符串列表;(2)自动补全:如果当前字符串是若干命令字符串的共同前缀,但不是最长共同前缀,则将其补充到最长前缀。eg:dic{document, doctor},输入Tab("d"), 返回"doc";(3)返回最少还需要输入多长的字符才能唯一确定一个...

words abbreviation

2016-07-30
阅读 3 分钟
2.3k
题目:在一个字典里有一堆英文单词,现在要把这些单词缩写成(前缀 + 字符串长度 + 尾字母)的形式,而且现在有两个限制条件:(1)要求缩写后的字符串可以唯一表示原单词;(2)有相同长度的单词在缩写后放在一起。

leetcode-WordLadder

2016-07-26
阅读 3 分钟
2.2k
题目:Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:

leetcode-Word Ladder II

2016-07-26
阅读 5 分钟
3.2k
题目:Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:

leetcode-Coin Change

2016-07-26
阅读 3 分钟
3.9k
题目:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.