diff --git a/00-chartgpt/chainlit/nohup.out b/00-chartgpt/chainlit/nohup.out index 50ee4a7839ab1274994076310a145a996d63dd34..c0e57c1a85438c43178f143bc2e4ae0c13c56e8b 100644 --- a/00-chartgpt/chainlit/nohup.out +++ b/00-chartgpt/chainlit/nohup.out @@ -140,3 +140,7 @@ openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectio engine was transferred to model_kwargs. Please confirm that engine is what you intended. 2023-06-23 14:38:43 - Your app is available at http://localhost:8000 +2023-06-23 19:57:00 - WARNING! engine is not default parameter. + engine was transferred to model_kwargs. + Please confirm that engine is what you intended. +2023-06-23 19:57:00 - Your app is available at http://localhost:8000 diff --git "a/14_\345\210\267\351\242\230/day02/problem_solving_16.py" "b/14_\345\210\267\351\242\230/day02/problem_solving_16.py" new file mode 100644 index 0000000000000000000000000000000000000000..9bebd00d217423eb39a484bef939e523666b381b --- /dev/null +++ "b/14_\345\210\267\351\242\230/day02/problem_solving_16.py" @@ -0,0 +1,32 @@ +""" +丢失的数字 +""" +from typing import List + + +class Solution: + def missingNumber(self, nums: List[int]) -> int: + nums.sort() + if nums[0] != 0: + return 0 + for i in range(1, len(nums)): + if nums[i] - nums[i - 1] > 1: + return nums[i] - 1 + return nums[-1] + 1 + + def missingNumber2(self, nums: List[int]) -> int: + """ + 主技巧 数学相关,求0到n的和 + :param nums: + :return: + """ + total = len(nums) * (len(nums) + 1) / 2 + sum_num = sum(nums) + return int(total - sum_num) + + +if __name__ == '__main__': + # root = Solution().missingNumber([3, 0, 1]) + # root = Solution().missingNumber([0, 1]) + root = Solution().missingNumber2([9, 6, 4, 2, 3, 5, 7, 0, 1]) + print(root) diff --git "a/14_\345\210\267\351\242\230/day02/problem_solving_17.py" "b/14_\345\210\267\351\242\230/day02/problem_solving_17.py" new file mode 100644 index 0000000000000000000000000000000000000000..d21da45a65bd05505c01010776912b19d7304f94 --- /dev/null +++ "b/14_\345\210\267\351\242\230/day02/problem_solving_17.py" @@ -0,0 +1,25 @@ +""" +移动零 +""" +from typing import List + + +class Solution: + def moveZeroes(self, nums: List[int]) -> None: + """ + Do not return anything, modify nums in-place instead. + """ + i = 0 + j = 0 + while j < len(nums): + if nums[j] != 0: + nums[i] = nums[j] + i += 1 + j += 1 + for index in range(i, len(nums)): + nums[index] = 0 + print(nums) + + +if __name__ == '__main__': + Solution().moveZeroes([0, 1, 0, 3, 12])