Bloomberg 实习店面

intdroduce talk - 11 mins
OOP - inheritance encapsulation - 15-20 mins
exact question longest substring non repeating - https://leetcode.com/problems/longest-substring-without-repeating-characters/ - 30 mins

only got O(n2) O(n2)… waffled for the last 7ish mins on improving O(n2) memory to O(n)…

class Solution {
    public int lengthOfLongestSubstring(String s) {  
        int n = s.length();
        int max = 0;
        for(int i=0; i<n; i++){
            HashSet<Character> set = new HashSet<Character>();
            int count = 0;
            for(int j=i; j<n; j++){
                if(set.contains(s.charAt(j))){
                    break;
                }else{
                    set.add(s.charAt(j));
                    count++;
                    if(count>max){
                        max = count;
                    }
                }
            }
        }
        return max;
    }
}