此题在LeetCode上难度标为Easy,LintCode上却标为Medium
这题虽然不能脱离IDE直接刷题,但没怎么被卡住,一天之内就做完了,还算简单吧。有共同前缀的字符串,它们的首字母肯定一样。
JavaScript
1 | /** |
Submission Detail
- 118 / 118 test cases passed.
- Your runtime beats 81.84 % of javascript submissions.
如果在
1 | if (b) |
后面加个break语句用于跳出循环判断,改成
1 | if (b) |
性能倒反降低了,这个有点不明白?
Java
1 | class Solution { |
Submission Detail
- 118 / 118 test cases passed.
- Your runtime beats 11.84 % of java submissions.
跟js代码的情况一样,加了跳出循环判断的break语句
1 | if (b) { |
性能倒反降低,不解?