摘要:
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.» Solve this problem[解题思路]从前往后扫描,用一个临时变量记录分段数字。如果当前比前一个大,说明这一段的值应该是当前这个值减去上一个值。比如IV = 5 – 1否则,将当前值加入到结果中,然后开始下一段记录。比如VI = 5 + 1, II=1+1 1 public static int romanToInt(String s) { 2 // St... 阅读全文
摘要:
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999. 1 public String intToRoman(int num) { 2 // Start typing your Java solution below 3 // DO NOT write main() function 4 StringBuffer result = new StringBuffer(); 5 ... 阅读全文
摘要:
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.255.11.135", "255.255.111.35"]. (Order does not matter)[解题思路]DFS + Backtracking给定的字符串分成4段,每段都0 剩余段数*32.剩余位数 restoreIpAddr 阅读全文
摘要:
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBANC"T="ABC"Minimum window is"BANC".Note:If there is no such window in S that covers all characters in T, return the emtpy 阅读全文