拖把套进来一下# Joke - 肚皮舞运动
d*m
1 楼
design a string class , with implementation of charAt() and substring(b,e),
with substring() requires O(1) time and O(1) space complexity
followup:
a new method setCharat(index, char) is added, a substring must keep the
changes of parent string that are made before its creation, but both the
parrent string and the substring will not affect each other after the
creation of the substring, requires O(1) space complexity。
前面的没啥好说的了,就是java里面string的原封不动的code,substring只要改下
char[]的offset和count就行了。没太明白后面的setCharAt怎么才能O(1)还能记录以前
所有的changes,还是O(1),提示是用tree或者arraylist of hashmap?
with substring() requires O(1) time and O(1) space complexity
followup:
a new method setCharat(index, char) is added, a substring must keep the
changes of parent string that are made before its creation, but both the
parrent string and the substring will not affect each other after the
creation of the substring, requires O(1) space complexity。
前面的没啥好说的了,就是java里面string的原封不动的code,substring只要改下
char[]的offset和count就行了。没太明白后面的setCharAt怎么才能O(1)还能记录以前
所有的changes,还是O(1),提示是用tree或者arraylist of hashmap?