微保笔试

这题目也太easy了吧,做了这么多次笔试最爽的一次 ,然而还是0offer
//无重复字符最长子串
//https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/solution/wu-zhong-fu-zi-fu-de-zui-chang-zi-chuan-by-leetcod/
//LC的官方解答,我差不多就这样写的
public class Solution {
    public int lengthOfLongestSubstring(String s) {
        int n = s.length();
        Set<Character> set = new HashSet<>();
        int ans = 0, i = 0, j = 0;
        while (i < n && j < n) {
            // try to extend the range [i, j]
            if (!set.contains(s.charAt(j))){
                set.add(s.charAt(j++));
                ans = Math.max(ans, j - i);
            }
            else {
                set.remove(s.charAt(i++));
            }
        }
        return ans;
    }
}


#微保WeSure#
全部评论
收到微众面试通知了吗
点赞 回复 分享
发布于 2020-04-16 20:33
AC了吗
点赞 回复 分享
发布于 2020-04-14 22:00
请问是数分的题么
点赞 回复 分享
发布于 2020-04-14 21:47
简单
点赞 回复 分享
发布于 2020-04-14 21:00
第一道算了半小时最后还是过了三分之二
点赞 回复 分享
发布于 2020-04-14 21:00
确实,做了10场笔试,笔试完之后都是没后续,估计微保这次也一样
点赞 回复 分享
发布于 2020-04-14 20:55

相关推荐

评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务