From aebadef17828690fee72c08d79f2c254168cd403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Thu, 29 Jun 2023 00:11:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=AC=AC=E4=B8=89=E5=A4=A7=E7=9A=84?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 00-chartgpt/chainlit/test_app.py | 3 +-- .../day03/problem_solving_21.py" | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 "14_\345\210\267\351\242\230/day03/problem_solving_21.py" diff --git a/00-chartgpt/chainlit/test_app.py b/00-chartgpt/chainlit/test_app.py index 72f2d18..1b309d8 100644 --- a/00-chartgpt/chainlit/test_app.py +++ b/00-chartgpt/chainlit/test_app.py @@ -1,9 +1,8 @@ import openai import chainlit as cl -openai.proxy = 'http://127.0.0.1:7890' +openai.proxy = 'http://127.0.0.1:8088' openai.api_key = "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" -# model_name = "text-davinci-003" model_name = "gpt-3.5-turbo" settings = { "temperature": 0.7, diff --git "a/14_\345\210\267\351\242\230/day03/problem_solving_21.py" "b/14_\345\210\267\351\242\230/day03/problem_solving_21.py" new file mode 100644 index 0000000..189cc04 --- /dev/null +++ "b/14_\345\210\267\351\242\230/day03/problem_solving_21.py" @@ -0,0 +1,22 @@ +""" +第三大的数 +""" +from typing import List + + +class Solution: + def thirdMax(self, nums: List[int]) -> int: + if not nums: + return None + if len(nums) < 3: + return max(nums) + nums = sorted(set(nums), reverse=True) + if len(nums) >= 3: + return nums[2] + else: + return max(nums) + + +if __name__ == '__main__': + result = Solution().thirdMax([3, 2, 1]) + print(result) -- GitLab