Day1-介绍与开始

嗨大家好~我是凯西!接下来是我开学的三十天实力增进计画的纪录

规划上会刷leetcode加强我的python、学习一些机器学习的知识
另外再分享一些其他我学到的东西!

先上第一天的暖身题目:

7. Reverse Integer(EASY)

Example 1:
Input: x = 123
Output: 321

Example 2:
Input: x = -123
Output: -321

Example 3:
Input: x = 120
Output: 21

Example 4:
Input: x = 0
Output: 0

constraints:
-231 <= x <= 231 - 1

以下是我的code:

def reverse(x):
    out = []
    negative = 0
    num = str(x)
    length = len(num)

    for i in range(length):

        if ord(num[i]) == 45:
            negative = 1
        else:
            out.append(num[i])

    out.reverse()
    out = "".join(out)

    #is negative and start with 0
    if (negative ==1) and (out[0]=='0'):
        out = -int(out[1:])
    elif (negative ==1) and (out[0]!='0'):
        out = -int(out)
    # start with 0 but not zero
    elif (out != '0') and (out[0] == '0'):
        out = int(out[1:])
    else:
        out = int(out)

    print(out)

那就先这样!
明天再写些厉害的!!


<<:  【D2】要下厨前需要准备锅具

>>:  听见「多少」下雨的声音

客户抱怨 v.s. 客户开发

自从到了美国之後,原本预期要来好好开发海外市场的,果然事情没有这麽顺利,既有客户所遇到的 Bug 跟...

[Day 4] laravel介绍

为什麽要选择laravel 我们常说:「不以规矩不能成方圆。」对一个程序初心者来说,写程序最容易遇到...

Day5-75. Sort Colors

今日题目:75. Sort Colors(Medium) Given an array nums w...

[Day 18] Sass - Mixins

@mixin 与 @include @mixin通常与@include一起使用, @mixin用来定...

Azure - Day5 Azure Function

Hi~大家好,我今天想要分享的实作包括如下: < Azure Function > 1....