Loading [MathJax]/jax/output/HTML-CSS/jax.js

Tuesday, August 13, 2019

Blog 復活

由以前研究數學,到突然想當美術,再到去大陸當美術之前,這個 blog 累積了不少內容。現在在香港當 developer,想嘗試把所學的東西整合放在這裏,也為了方便自己工作做個紀錄。例如怎様 init 一個 react project 都已經忘了 ...,如果以前有在這邊做紀錄的話就可以直接 copy and paste 了。也由於有在上 data science course 的關係,基於自己的數學背景沒有辦法不執着背後定理的證明(接受不了把定理當成理所當然),所以也會順便把有深入研究到的相關證明寫到這裏。

看到以前那些不堪入目的畫作 ...,練畫真的有血有淚啊。

為了熟習 C# 的 syntax 所以做了一些簡單的 Leetcode 題目,
以下測試 syntaxhighlighter,我的 code 是解答這題:
https://leetcode.com/problems/longest-substring-without-repeating-characters/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
 
namespace Leetcode
{
    public class Solution
    {
        public int LengthOfLongestSubstring(string s)
        {
            if (s.Length < 2)
            {
                return s.Length;
            }
            else
            {
                var resultingLengths = new List<int>();
                for (int i = 0; i < s.Length - 1; i++)
                {
                    int count = 1;
                    string substring = Convert.ToString(s[i]);
                    for (int j = i + 1; j < s.Length; j++)
                    {
                        if (substring.IndexOf(s[j]) != -1)
                        {
                            break;
                        }
                        else
                        {
                            substring += s[j];
                            count++;
                        }
                    }
                    resultingLengths.Add(count);
                }
                return resultingLengths.Max();
            }
        }
    }
}

No comments:

Post a Comment