From ea034289f91f1fccf16618758fd57bd807a84aa4 Mon Sep 17 00:00:00 2001 From: xuexi21 Date: Mon, 1 May 2023 23:27:25 +0200 Subject: [PATCH 1/2] change to kai name --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 96f7e1c..83ca47b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # test_git Learn how to use git properly -# ANNA update after Main branch protection +# KAI update after Main branch protection + + ## Please be freindly to Bigginer.## From b255c38b71a7698f081939df3b98ccaa16a577c9 Mon Sep 17 00:00:00 2001 From: Xuekai Li Date: Wed, 11 Sep 2024 21:48:25 +0200 Subject: [PATCH 2/2] FIRST CONNECT WITH VSCODE --- .gitignore | 0 LICENSE | 0 README.md | 0 test.ipynb | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 77 insertions(+), 2 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 test.ipynb diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/test.ipynb b/test.ipynb old mode 100644 new mode 100755 index 50e5485..0098735 --- a/test.ipynb +++ b/test.ipynb @@ -5,13 +5,88 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "JUST FOR TEST" + "75.\n", + "\n", + "Given an array `nums` with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.\n", + "\n", + "We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.\n", + "\n", + "You must solve this problem without using the library's sort function.\n", + "\n", + " \n", + "\n", + "Example 1:\n", + "\n", + "Input: nums = $[2,0,2,1,1,0]$\n", + "Output: [0,0,1,1,2,2]\n", + "Example 2:\n", + "\n", + "Input: nums = [2,0,1]\n", + "Output: [0,1,2]\n", + " \n", + "\n", + "Constraints:\n", + "\n", + "n == nums.length\n", + "1 <= n <= 300\n", + "nums[i] is either 0, 1, or 2.\n", + " \n", + "\n", + "Follow up: Could you come up with a one-pass algorithm using only constant extra space?" ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "class Solution(object):\n", + " def sortColors(self, nums):\n", + " \"\"\"\n", + " :type nums: List[int]\n", + " :rtype: None Do not return anything, modify nums in-place instead.\n", + " \"\"\"\n", + " low, mid, high = 0, 0, len(nums) - 1\n", + " \n", + " while mid <= high:\n", + " if nums[mid] == 0:\n", + " nums[low], nums[mid] = nums[mid], nums[low]\n", + " low += 1\n", + " mid += 1\n", + " elif nums[mid] == 1:\n", + " mid += 1\n", + " else:\n", + " nums[mid], nums[high] = nums[high], nums[mid]\n", + " high -= 1\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { + "kernelspec": { + "display_name": "py310", + "language": "python", + "name": "python3" + }, "language_info": { - "name": "python" + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.13" }, "orig_nbformat": 4 },