中级农民
- 积分
- 115
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2019-12-7
- 最后登录
- 1970-1-1
|
06.15 刷题第四天 打卡第四天
1. String replace
Mindset: choose one solution from "in-place" or using a "StringBuilder"
In order to achieve lower time complexity, I would rather choose "in-place"
but with the succinct of code.
a. Separate it into shorter and longer
b. use slow and fast pointer
c. Both needed to copied by using the target String
d. watch out for array index out of bound issue
2. Longest subString without repeating(Only need return the length of subString)
Mindset: use HashSet and three variables(slow, fast, longest);
Given a string, find the longest substring without any repeating characters and return the length of it. The input string is guaranteed to be not null.
3. longest subArray contains only 1s
Mindset:
use four variables
slow, fast, longest, count(to calculate how many flips we had used for now)
|
|