[#0166] feat(leetcode): init project

This commit is contained in:
2025-09-24 09:35:00 +08:00
parent 959f8a6861
commit 5189c524ef
9 changed files with 220 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
# [166] Fraction To Recurring Decimal
## 題目資訊
- **難度**: Medium
- **標籤**:
- **題目連結**: https://leetcode.com/problems/fraction-to-recurring-decimal/
- **練習日期**: 2025-09-24
- **目標複雜度**: 時間 O(?)、空間 O(?)
## 題目描述
> 在這裡貼上題目的完整描述(或重點)
## 先備條件與限制
- 輸入限制n ∈ [?, ?]、值域 ∈ [?, ?]
- 回傳/輸出格式:...
- 其他:是否允許排序/就地修改
## 解題思路
### 初步分析
- 類型:雙指針 / 滑動視窗 / 排序 / DP / 貪心 / 圖論 ...
- 關鍵觀察:
- 複雜度目標理由:
### 解法比較
1. 解法A基準/暴力):
- 思路:
- 正確性:
- 複雜度O(?) / O(?)
2. 解法B優化
- 思路:
- 正確性:
- 複雜度O(?) / O(?)
### 乾跑Dry Run
- 範例:...
## 實作細節與 API 設計
### C# 方法簽名(示意)
```csharp
public class Solution {
// TODO: 根據題意調整簽名
public int Solve(int[] nums) {
return 0;
}
}
```
### Go 方法簽名(示意)
```go
func solve(nums []int) int {
return 0
}
```
### 常見陷阱
- 邊界:空/單一/極值/全相等
- 去重:排序後跳重複、集合
- 溢位:使用 64-bit
## 測試案例
### 範例輸入輸出
```
Input: ...
Output: ...
Explanation: ...
```
### 邊界清單
- [ ] 空陣列/空字串
- [ ] 單一元素 / 全相同
- [ ] 含負數/0/大數
- [ ] 去重
- [ ] 大資料壓力
## 複雜度分析
- 最壞:時間 O(?)、空間 O(?)
## 相關題目 / Follow-up
-
## 學習筆記
- 今天學到:
- 卡住與修正:
- 待優化:
---
**總結**:這題的核心在於 ______,適合練習 ______

View File

@@ -0,0 +1,24 @@
// LeetCode 166: Fraction To Recurring Decimal
// 難度: Medium
// 日期: 2025-09-24
using System;
using System.Collections.Generic;
using System.Linq;
public class Solution {
// TODO: 根據題意調整簽名
public int Solve(int[] nums) {
// 實作解法
return 0;
}
}
public class Program {
public static void Main() {
var s = new Solution();
// TODO: 可加入簡單輸入/輸出測試
Console.WriteLine("Hello LeetCode 166!");
}
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,3 @@
module leetcode-166
go 1.18

View File

@@ -0,0 +1,18 @@
// LeetCode 166: Fraction To Recurring Decimal
// 難度: Medium
// 日期: 2025-09-24
package main
import "fmt"
// TODO: 根據題意調整簽名
func solve(nums []int) int {
return 0
}
func main() {
fmt.Printf("Hello LeetCode 166!\n")
// TODO: 可加入簡單測試
}

View File

@@ -0,0 +1,24 @@
// LeetCode 166 單元測試xUnit
using Xunit;
public class SolutionTests {
private readonly Solution _s = new Solution();
[Fact]
public void Example1() {
// TODO: Arrange
// var input = new int[] { };
// var expected = 0;
// Act
// var got = _s.Solve(input);
// Assert.Equal(expected, got);
Assert.True(true);
}
[Fact]
public void EdgeCases() {
Assert.True(true);
}
}

View File

@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../csharp/csharp.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,20 @@
# 邊界情況清單166 Fraction To Recurring Decimal
## 需要測試的邊界
- [ ] 空輸入 / 單一元素
- [ ] 重複元素 / 全相同
- [ ] 極值(最小/最大)
- [ ] 含負數 / 0 / 大數
- [ ] 大資料量(接近上限)
## 額外案例
### 案例 1
- 輸入:
- 預期:
- 說明:
### 案例 2
- 輸入:
- 預期:
- 說明:

View File

@@ -0,0 +1,12 @@
// LeetCode 166 單元測試Go testing
package main
import "testing"
func TestExample(t *testing.T) {
// TODO: input := []int{}
// got := solve(input)
// want := 0
// if got != want { t.Fatalf("want %v got %v", want, got) }
}