From df4e3e929cfb6e28c0cd38edb474d6ebdfae0639 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Thu, 23 May 2024 10:17:15 +0800 Subject: [PATCH] 20240523 Finished --- .idea/.idea.LeetCodeSharp/.idea/.gitignore | 13 ++++++ .idea/.idea.LeetCodeSharp/.idea/encodings.xml | 4 ++ .../.idea.LeetCodeSharp/.idea/indexLayout.xml | 8 ++++ .idea/.idea.LeetCodeSharp/.idea/vcs.xml | 6 +++ LeetCodeSharp/Problems/Solution141.cs | 46 +++++++++++++++++++ commit.sh | 11 +++++ 6 files changed, 88 insertions(+) create mode 100644 .idea/.idea.LeetCodeSharp/.idea/.gitignore create mode 100644 .idea/.idea.LeetCodeSharp/.idea/encodings.xml create mode 100644 .idea/.idea.LeetCodeSharp/.idea/indexLayout.xml create mode 100644 .idea/.idea.LeetCodeSharp/.idea/vcs.xml create mode 100644 LeetCodeSharp/Problems/Solution141.cs create mode 100755 commit.sh diff --git a/.idea/.idea.LeetCodeSharp/.idea/.gitignore b/.idea/.idea.LeetCodeSharp/.idea/.gitignore new file mode 100644 index 0000000..2cfe808 --- /dev/null +++ b/.idea/.idea.LeetCodeSharp/.idea/.gitignore @@ -0,0 +1,13 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# Rider 忽略的文件 +/contentModel.xml +/.idea.LeetCodeSharp.iml +/modules.xml +/projectSettingsUpdater.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.LeetCodeSharp/.idea/encodings.xml b/.idea/.idea.LeetCodeSharp/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.LeetCodeSharp/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.LeetCodeSharp/.idea/indexLayout.xml b/.idea/.idea.LeetCodeSharp/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.LeetCodeSharp/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.LeetCodeSharp/.idea/vcs.xml b/.idea/.idea.LeetCodeSharp/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/.idea.LeetCodeSharp/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LeetCodeSharp/Problems/Solution141.cs b/LeetCodeSharp/Problems/Solution141.cs new file mode 100644 index 0000000..056b38a --- /dev/null +++ b/LeetCodeSharp/Problems/Solution141.cs @@ -0,0 +1,46 @@ +// [141] Linked List Cycle + +using System.Collections.Generic; +using LeetCodeSharp.Utils; + +namespace LeetCodeSharp.Problems141 +{ + // Submission codes start here + + /** + * Definition for singly-linked list. + * public class ListNode { + * public int val; + * public ListNode next; + * public ListNode(int x) { + * val = x; + * next = null; + * } + * } + */ + public class Solution + { + private readonly HashSet _visited = new HashSet(); + + public bool HasCycle(ListNode head) + { + _visited.Clear(); + ListNode node = head; + + while (node != null) + { + if (_visited.Contains(node)) + { + return true; + } + + _visited.Add(node); + node = node.next; + } + + return false; + } + } + + // Submission codes end here +} \ No newline at end of file diff --git a/commit.sh b/commit.sh new file mode 100755 index 0000000..506d674 --- /dev/null +++ b/commit.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +time=$(date "+%Y%m%d") +message="$time Finished" + +git add -A +git commit -m "$message" + +git push