Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c7a3220
tuantai0708 - Day2507
tuantai1522 Jul 25, 2024
3acad51
tuantai0708 - Day2607
tuantai1522 Jul 26, 2024
c87f609
tuantai0708 - Day2707
tuantai1522 Jul 27, 2024
e273ba2
tuantai0708 - Day2807
tuantai1522 Jul 28, 2024
a9bb884
tuantai0708 - Day2307
tuantai1522 Jul 30, 2024
91181fb
tuantai0708 - Day2407
tuantai1522 Jul 31, 2024
687b427
tuantai0708 - Day2207
tuantai1522 Aug 1, 2024
0764324
tuantai0708 - Day0508
tuantai1522 Aug 5, 2024
bad073d
tuantai0708 - Day0608
tuantai1522 Aug 6, 2024
fd97000
tuantai0708 - Day0708
tuantai1522 Aug 7, 2024
08b3a56
tuantai0708 - Day0808
tuantai1522 Aug 8, 2024
1a7a9c1
tuantai0708 - Day0908
tuantai1522 Aug 9, 2024
7735b0e
tuantai0708 - Day1008
tuantai1522 Aug 10, 2024
5c1659a
tuantai0708 - Day1308
tuantai1522 Aug 13, 2024
7435b95
tuantai0708 - Day1408
tuantai1522 Aug 14, 2024
61ba7e4
tuantai0708 - Day1508
tuantai1522 Aug 15, 2024
d1629a2
tuantait0708 - Day1608
tuantai1522 Aug 16, 2024
2b64003
tuantai0708 - Day1708
tuantai1522 Aug 17, 2024
36d7f61
tuantai0708 - Day1808
tuantai1522 Aug 19, 2024
332f05d
tuantai0708 - Day1908
tuantai1522 Aug 19, 2024
83f3980
tuantai0708 - Day2008
tuantai1522 Aug 21, 2024
d52529b
tuantai0708 - Day2108
tuantai1522 Aug 21, 2024
213e06b
tuantai0708 - Day2208
tuantai1522 Aug 22, 2024
56a7476
tuantai0708 - Day2308
tuantai1522 Aug 23, 2024
2faca05
tuantai0708 - Day2708
tuantai1522 Aug 28, 2024
c56371c
tuantai0708 - Day2808
tuantai1522 Aug 28, 2024
62ad9e5
tuantai0708 - Day2908
tuantai1522 Aug 29, 2024
2a8f8f5
tutantai0708 - Day3008
tuantai1522 Aug 30, 2024
c55076f
tuantai0708 - Day3108
tuantai1522 Aug 31, 2024
4aab031
tuantai0708 - Day0109
tuantai1522 Sep 2, 2024
930e10b
tuantai0708 - Day0209
tuantai1522 Sep 2, 2024
3df858a
tuantai0708 - Day0309
tuantai1522 Sep 4, 2024
135d3f0
tuantai0708 - Day0409
tuantai1522 Sep 4, 2024
450cb6b
tuantai0708 - Day0509
tuantai1522 Sep 5, 2024
ed38b93
tuantai0708 - Day0609
tuantai1522 Sep 6, 2024
f1599cc
tuantai0708 - Day0709
tuantai1522 Sep 7, 2024
cc720b1
tuantai0708 - Day1109
tuantai1522 Sep 11, 2024
305874f
tuantai0708 - Day1209
tuantai1522 Sep 12, 2024
e9cac60
tuantai0708 - Day1309
tuantai1522 Sep 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 229 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
# The following command works for downloading when using Git for Windows:
# curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
#
# Download this file using PowerShell v3 under Windows with the following comand:
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
#
# or wget:
# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
x64/
[Bb]in/
[Oo]bj/
# build folder is nowadays used for build scripts and should not be ignored
#build/

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sln
*.csproj

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
modulesbin/
tempbin/

# EPiServer Site file (VPP)
AppData/

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# vim
*.txt~
*.swp
*.swo

# Temp files when opening LibreOffice on ubuntu
.~lock.*

# svn
.svn

# CVS - Source Control
**/CVS/

# Remainings from resolving conflicts in Source Control
*.orig

# SQL Server files
**/App_Data/*.mdf
**/App_Data/*.ldf
**/App_Data/*.sdf


#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# OS generated files #
Icon?

# Mac desktop service store files
.DS_Store

# SASS Compiler cache
.sass-cache

# Visual Studio 2014 CTP
**/*.sln.ide

# Visual Studio temp something
.vs/

# dotnet stuff
project.lock.json

# VS 2015+
*.vc.vc.opendb
*.vc.db

# Rider
.idea/

# Visual Studio Code
.vscode/

# Output folder used by Webpack or other FE stuff
**/node_modules/*
package-lock.json
**/wwwroot/*

# SpecFlow specific
*.feature.cs
*.feature.xlsx.*
*.Specs_*.html

# UWP Projects
AppPackages/

#####
# End of core ignore list, below put you custom 'per project' settings (patterns or path)
#####
43 changes: 43 additions & 0 deletions Topic1_Arrays/Day2207/Exercise1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//https://leetcode.com/problems/two-sum/submissions/1340665663/

/*
+ To use Dictionary
+ Key: current value
+ Value: idx of its
+ When looping every single element, I need to get target minus current value to find
whether that value exists in dictionary or not
+ If it doesn't exist => add to dictionary
+ If it exists => add to result array to return

Space complexity: O(n)
Time complexity: O(n)
*/

namespace Day2207
{
public class Exercise1
{
public int[] TwoSum(int[] nums, int target)
{
Dictionary<int, int> myDict = new();

int[] result = new int[2];

for (int i = 0; i < nums.Length; ++i)
{
int calc = target - nums[i];
if (myDict.ContainsKey(calc))
{
result[0] = myDict[calc];
result[1] = i;
break;

}
else
myDict[nums[i]] = i;
}

return result;
}
}
}
52 changes: 52 additions & 0 deletions Topic1_Arrays/Day2207/Exercise2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//https://leetcode.com/problems/number-of-islands/description/

/*
+ To use recursion technique
+ I will loop every single element in 2d arrays
+ If current value is '1' => not visited => backtracking that position and plus 1 value of result
+ When backtracking current position, mark its neightbor values as '2' (islands but visited)

Space complexity: O(n^2)
Time complexity: O(1)
*/

namespace Day2207
{
public class Exercise2
{
public int NumIslands(char[][] grid)
{
int row = grid.Length;
int col = grid[0].Length;

int result = 0;

for (int i = 0; i < row; ++i)
{
for (int j = 0; j < col; ++j)
{
if (grid[i][j] == '1')
{
++result;
Backtrack(grid, i, j, row, col);
}
}
}

return result;
}

private void Backtrack(char[][] grid, int i, int j, int m, int n)
{
if (i < 0 || i == m || j < 0 || j == n || grid[i][j] != '1')
return;

grid[i][j] = '2'; // visited

Backtrack(grid, i - 1, j, m, n);
Backtrack(grid, i, j - 1, m, n);
Backtrack(grid, i + 1, j, m, n);
Backtrack(grid, i, j + 1, m, n);
}
}
}
36 changes: 36 additions & 0 deletions Topic1_Arrays/Day2207/Exercise3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//https://leetcode.com/problems/merge-sorted-array/

/*
+ I will have 2 pointers at the end of every array
+ when comparing 2 current values in array, I need to move larger value into the end of array
+ Fill all remaining values of nums2 array into nums1 array

Space complexity: O(m + n)
Time complexity: O(1)
*/

namespace Day2207
{
public class Exercise3
{
public void Merge(int[] nums1, int m, int[] nums2, int n)
{
int i = m - 1;
int j = n - 1;
int k = nums1.Length - 1;

while (i >= 0 && j >= 0)
{
if (nums1[i] >= nums2[j])
nums1[k--] = nums1[i--];
else
nums1[k--] = nums2[j--];
}


//fill all remaining elements in nums2 array into nums1 array
while (j >= 0)
nums1[k--] = nums2[j--];
}
}
}
Loading