\( \newcommand{\N}{\mathbb{N}} \newcommand{\R}{\mathbb{R}} \newcommand{\C}{\mathbb{C}} \newcommand{\Q}{\mathbb{Q}} \newcommand{\Z}{\mathbb{Z}} \newcommand{\P}{\mathcal P} \newcommand{\B}{\mathcal B} \newcommand{\F}{\mathbb{F}} \newcommand{\E}{\mathcal E} \newcommand{\brac}[1]{\left(#1\right)} \newcommand{\abs}[1]{\left|#1\right|} \newcommand{\matrixx}[1]{\begin{bmatrix}#1\end {bmatrix}} \newcommand{\vmatrixx}[1]{\begin{vmatrix} #1\end{vmatrix}} \newcommand{\lims}{\mathop{\overline{\lim}}} \newcommand{\limi}{\mathop{\underline{\lim}}} \newcommand{\limn}{\lim_{n\to\infty}} \newcommand{\limsn}{\lims_{n\to\infty}} \newcommand{\limin}{\limi_{n\to\infty}} \newcommand{\nul}{\mathop{\mathrm{Nul}}} \newcommand{\col}{\mathop{\mathrm{Col}}} \newcommand{\rank}{\mathop{\mathrm{Rank}}} \newcommand{\dis}{\displaystyle} \newcommand{\spann}{\mathop{\mathrm{span}}} \newcommand{\range}{\mathop{\mathrm{range}}} \newcommand{\inner}[1]{\langle #1 \rangle} \newcommand{\innerr}[1]{\left\langle #1 \right \rangle} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\toto}{\rightrightarrows} \newcommand{\upto}{\nearrow} \newcommand{\downto}{\searrow} \newcommand{\qed}{\quad \blacksquare} \newcommand{\tr}{\mathop{\mathrm{tr}}} \newcommand{\bm}{\boldsymbol} \newcommand{\cupp}{\bigcup} \newcommand{\capp}{\bigcap} \newcommand{\sqcupp}{\bigsqcup} \newcommand{\re}{\mathop{\mathrm{Re}}} \newcommand{\im}{\mathop{\mathrm{Im}}} \newcommand{\comma}{\text{,}} \newcommand{\foot}{\text{。}} \)

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/
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