耗子叔ARTS:第十周

Algorithm:

7.给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。

示例 1:

输入: 123
输出: 321
 示例 2:

输入: -123
输出: -321
示例 3:

输入: 120
输出: 21
注意:

假设我们的环境只能存储得下 32 位的有符号整数,则其数值范围为 [−231,  231 − 1]。请根据这个假设,如果反转后整数溢出那么就返回 0。

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/reverse-integer
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

class Solution:
    def reverse(self, x: int) -> int:
        # 转换成字符串在进行翻转生成列表再拼成字符串
        reverse_str = ''.join(list(reversed(str(x))))
        # 如果为-,切掉最后的-符号,然后再将字符串转成int输出
        if '-' in reverse_str:
            res = int(reverse_str[:-1])*-1
        else:
            res = int(reverse_str)
        # 用If判断,不过感觉更好的方法是用try语句
        if res >(2**31-1) or res < (-2)**31:
            return 0
        else: 
            return res

 Review:http://www.enread.com/news/business/109576.html

Alipay is a global Internet services leader because of its ability to innovate1 as it rolled out services to more than 1 billion people globally, according to the 2019 edition of the "Internet Trends Report" released on Wednesday by the legendary2 Internet stock analyst3 and investor4, Mary Meeker5.

 

支付宝的创新能力使它成为全球互联网服务领头羊,目前支付宝全球用户数量10亿多人。

 

Meeker describes Alipay has having evolved into a super app from its beginnings as an electronic wallet, as it has expanded to include more than 200,000 applets. The report says more than 70 percent of Alipay users have used more than three of the financial services on offer, such as Ant Forest and Urban Services, which both have 500 million users.

 

Ant Forest encourages users to collect points for engaging in low-carbon activities, such as using public transport; after a certain number of points are collected, Ant Financial and its partners plant a tree as a contribution to China's efforts to prevent desertification. Alipay's Urban Services provides online access to government services.

 

According to data from the analytics company App Annie, Alipay is the non-social media app with the world's largest number of users. And the latest data released by the consulting firm Trustdata says that Alipay has become the app with the second-largest user base in China.

 

The "Internet Trends Report", now in its 23rd year, compiles and crunches6 data from a wide range of sources to provide insights into the biggest trends in digital services.

Tip:

进行单元测试的编写:

  @RunWith(MockitoJUnitRunner.class) 
    @Mock
    RestTemplate restTemplate;
    @Mock
    XXXClient client;
    @InjectMocks
    ServiceImpl serviceImpl;

@before

MockitoAnnotations.intiMocks(this)

mokito mock的方法的参数要么全部使用mock方式,要不全都不适用mock方式。

有的参数用真实参数,有的用mockito.eq(类名) 

会抛出 org.mockito.exections.misusing.InvalidUseOfMatchersException:

Invaild use of argument matchers!

Share:https://mp.weixin.qq.com/s/AjscejPieCYik7ORMCgH7A 

给程序员的几条建议,精彩配图

程序员 芋道源码 4月6日

点击上方“芋道源码”,选择“设为星标

做积极的人,而不是积极废人!

源码精品专栏

 

来源:http://t.cn/RYytjpZ

  • 1. 想清楚,再动手写代码

  • 2. 不交流,就会头破血流

  • 3. 文档没人看,但还是要写

  • 4. 一定要写注释

  • 5. 别指望需求会稳定

  • 6. 业务高于技术

  • 7. 不要心存侥幸

  • 8. 自己先测几遍

  • 9. 尽可能自己解决问题

  • 10. 慎用新技术


1. 想清楚,再动手写代码

刚入行的新手,为了展示自己的能力,拿到需求迫不及待地就开始上手写代码,大忌!

 

2. 不交流,就会头破血流

不爱说话和沟通,需求都理解错误了,最后做出来才发现,只能加班返工。

 

3. 文档没人看,但还是要写

文档的作用大部分时候不是用来沟通的,是用来做记录的,大部分需求还是通过口头沟通,但是不写文档做记录,后续就容易扯皮。

 

4. 一定要写注释

时间久了,你会连自己的代码都看不懂。

 

5. 别指望需求会稳定

产品需求是根据商业需求不断调整的,改需求是再正常不过的事,别抱怨。

 

6. 业务高于技术

如果技术不为公司商业做服务,那将毫无价值,公司赚钱才是硬道理。

 

7. 不要心存侥幸

你隐约感觉会出bug的地方,就一定会出bug。

 

8. 自己先测几遍

不要写完就扔给测试人员去测,经自己手的东西,要保证质量。

 

9. 尽可能自己解决问题

遇到不懂的问题,要先尽力解决,别动不动就截个图扔在别人求帮忙,上司和同事不是来给你擦屁股的,但是真的搞砸了就要尽快求助。

 

10. 慎用新技术

新技术是好东西,但没有百分百把握,自作主张用了,多半是作死。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值