May 24, 2016
Work on the algorithm. The string "eoeab", the longest substring with at most two distinct characters is "eoe", and the length is 3.
1. Read the blog about solution:
http://yuanhsh.iteye.com/blog/2188917
Brute force solution: O(n^3)
Sliding window - better solution O(n) solution in time complexity
2. Study the code:
https://github.com/jianminchen/LeetCode-Java-Solutions/blob/master/159.longest-substring-with-at-most-two-distinct-characters.java
Write C# code:
https://gist.github.com/jianminchen/9061c12fee5e050e56a98cb3ffcc6f57
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Tuesday, May 24, 2016
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment