[RATS]week-6

2024-02-07 05:40
文章标签 week rats

本文主要是介绍[RATS]week-6,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

[RATS]week-6

  • Algorithm
    • Question
    • Answer
    • Result
  • Review
    • Spring Cloud - Spring Cloud Netflix
  • Tips - Spring AOP增强生效的三种方法
  • Share - Python && Kotlin from infoQ
    • google 搜索频次
    • 平均薪资

Algorithm

Question

请你来实现一个 atoi 函数,使其能将字符串转换成整数。
首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。
当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号;假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。
该字符串除了有效的整数部分之后也可能会存在多余的字符,这些字符可以被忽略,它们对于函数不应该造成影响。
注意:假如该字符串中的第一个非空格字符不是一个有效整数字符、字符串为空或字符串仅包含空白字符时,则你的函数不需要进行转换。
在任何情况下,若函数不能进行有效的转换时,请返回 0。
说明:
假设我们的环境只能存储 32 位大小的有符号整数,那么其数值范围为 [−231, 231 − 1]。如果数值超过这个范围,请返回 INT_MAX (231 − 1) 或 INT_MIN (−231) 。
示例 1:
输入: “42”
输出: 42
示例 2:
输入: " -42"
输出: -42
解释: 第一个非空白字符为 ‘-’, 它是一个负号。
我们尽可能将负号与后面所有连续出现的数字组合起来,最后得到 -42 。
示例 3:
输入: “4193 with words”
输出: 4193
解释: 转换截止于数字 ‘3’ ,因为它的下一个字符不为数字。
示例 4:
输入: “words and 987”
输出: 0
解释: 第一个非空字符是 ‘w’, 但它不是数字或正、负号。
因此无法执行有效的转换。
示例 5:
输入: “-91283472332”
输出: -2147483648
解释: 数字 “-91283472332” 超过 32 位有符号整数范围。
因此返回 INT_MIN (−231) 。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/string-to-integer-atoi
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

Answer

   public int myAtoi(String str) {char[] charArray = str.toCharArray();char space1 = 160;char space2 = 32;char minus = 45,plus = 43;char minDigitalChar = 48;char maxDigitalChar = 57;StringBuilder sb = new StringBuilder();for (char c : charArray) {if (sb.length() == 0 && (c == space1 || c == space2)) {continue;}if (sb.length() == 0 && (c < minDigitalChar || c > maxDigitalChar) && minus != c && plus != c) {return 0;}if (sb.length() > 0 && (c < minDigitalChar || c > maxDigitalChar)) {break;}sb.append(c);if("-".compareTo(sb.toString()) == 0 || "+".compareTo(sb.toString()) == 0) continue;Long l = Long.valueOf(sb.toString());if (l > Integer.MAX_VALUE) {return Integer.MAX_VALUE;}if (l < Integer.MIN_VALUE) {return Integer.MIN_VALUE;}}if(sb.length() == 0) return 0;if("-".compareTo(sb.toString()) == 0 || "+".compareTo(sb.toString()) == 0) return 0;Long l = Long.valueOf(sb.toString());if (l > Integer.MAX_VALUE) {return Integer.MAX_VALUE;}if (l < Integer.MIN_VALUE) {return Integer.MIN_VALUE;}return l.intValue();}

Result

在这里插入图片描述

Review

Spring Cloud - Spring Cloud Netflix

Spring Cloud Stream is a framework for building highly scalable event-driven microservices connected with shared messaging systems.
The framework provides a flexible programming model built on already established and familiar Spring idioms and best practices, including support for persistent pub/sub semantics, consumer groups, and stateful partitions.

Spring Cloud Stream 是一套构建高扩展的事件驱动的链接共享消息系统的微服务架构。这套框架提供了*灵活的构建在一部书的稳定的和类似Spring习惯和最佳时间的编程模型,包括了支持发布发布/订阅模型,消费者组和状态分区

Binder Implementations
Spring Cloud Stream supports a variety of binder implementations and the following table includes the link to the GitHub projects.
· RabbitMQ
· Apache Kafka
· Kafka Streams
· Amazon Kinesis
· Google PubSub (partner maintained)
· Solace PubSub+ (partner maintained)
· Azure Event Hubs (partner maintained)
· Apache RocketMQ (partner maintained)
The core building blocks of Spring Cloud Stream are:
·Destination Binders: Components responsible to provide integration with the external messaging systems.
·Destination Bindings: Bridge between the external messaging systems and application provided Producers and Consumers of messages (created by the Destination Binders).
·Message: The canonical data structure used by producers and consumers to communicate with Destination Binders (and thus other applications via external messaging systems).

**Binder Implementations
Spring CLoud Stream 支持多种类型的binder implementations和下面表格中包括的GitHub上的项目链接
· RabbitMQ
· Apache Kafka
· Kafka Streams
· Amazon Kinesis
· Google PubSub (partner maintained)
· Solace PubSub+ (partner maintained)
· Azure Event Hubs (partner maintained)
· Apache RocketMQ (partner maintained)
这个核心构建Spring Cloud Stream 组成部分是:
· Destination Binders:组件负责集成提供外部消息传送系统
· Destination Bindings:外部消息传送系统和应用程序之间的桥提供了生产者与消费者的消息(Destination Binders创建)
· 信息:生产者和消费者使用的典型数据结构在Destination Binders之间传递消息。
**

Tips - Spring AOP增强生效的三种方法

1.把Service自己作为Bean注入到Service中,
2.使用ApplicationContext
3.使用AopContext

Demo 如下

public DemoService{@Autowiredprivate DemoService demoService;@Autowiredprivate ApplicationContext appContext;@Transactionalpublic void method1(){}@Transactionalpublic void method2(){}public void invokeWithSelf(){demoService.method1();demoService.method2();}public void invokeWithAppContext(){DemoService service = (DemoService)appContext.getBean(DemoService.class);service.method1();service.method2();}public void invokeWithAopContext(){Demoservice service = (DemoService)AopContext.currentProxy();service.method1();service.method2();}
}

注意要使用AopContext.currentProxy()时,需要在程序main入口的类添加@EnableAspectJAutoProxy(exposeProxy = true)

@EnableAspectJAutoProxy(exposeProxy = true)
public class DemoApplication{public static void main(String[] args){SpringApplication.run(DemoApplication.class, args);}
}

以上自极客时间-《MySQL实战45讲》学习笔记

Share - Python && Kotlin from infoQ

google 搜索频次

在这里插入图片描述

平均薪资

在这里插入图片描述

Python 正在蚕食编程语言的世界。今年 4 月,外媒 ZDNet援引 SlashData 的数据表示,目前全球范围有 820 万开发者使用 Python 进行编码,其数量已超过拥有 760 万使用者的 Java。去年 9 月,它们的用户数还分别为 700 万(Python)和 710 万(Java)。有分析称,机器学习的兴起是 Python 崛起的重要推动因素。现在,高达 69%的机器学习开发人员和数据科学家都在使用 Python。通过下表,你还可以看到,尽管 Python 的平均薪资较去年有所回落,但与其他语言相比仍具竞争力。
与之相应地,一些科技巨头都在使用 Python。例如,Google 从人工智能算法到云应用引擎等领域都使用 Python;Dropbox 99.9% 的代码是用 Python 编写的,包括服务器后端、桌面客户端、网站控制器逻辑、API 后端和分析工具等。

在这里插入图片描述

目前,Kotlin 主要用来构建 Android 应用程序。根据 JetBrains 最近的一项调查,大约 62% 的开发人员正在使用 Kotlin 构建移动应用程序,41% 的开发人员用它完成 Web 后端项目,库占 29%,工具占 22%,9% 的受访者将其用于桌面应用程序,7% 的受访者将其用于构建物联网。Kotlin 的势头很可能在未来几年才会爆发,当前,它距离完全超越 Java 还有很长一段路要走。
Java 与 Kotlin 之间的关系同 Objective-C 与 Swift 有些类似。但不同的是,后者间的“对决”显然更加白热化,Objective-C 与 Swift 分别位列排行榜第八、九位,份额仅差 0.17%,而 Objective-C 的搜索趋势较 Swift 低 0.4 个百分点。
此外,榜单中,上升幅度同比增长较多的还有 Go,Rust,JavaScript,Julia;与之相对地,Ruby,Scala,Perl,Visual Basic,Lua,Delphi 则有所下降。

这篇关于[RATS]week-6的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/686674

相关文章

MATH36022 Numerical Analysis 2 Approximation of Functions – Week 3 Exercises

Show that the Chebyshev polynomials are orthogonal on ( − 1 , 1 ) (−1, 1) (−1,1) with respect to the weight function ( 1 − x 2 ) − 1 / 2 (1 − x^2)^{−1/2} (1−x2)−1/2. Ans: T n ( x ) = cos ⁡ ( n arcc

MATH36022 Numerical Analysis 2 Approximation of Functions – Week 2 Exercises

Attempt these exercises in advance of the tutorial in Week 3 Find the best L ∞ L_\infin L∞​ approximation to f ( x ) = x n + 1 + ∑ k = 0 n a k x k f (x) = x^{n+1} + \sum_{k=0}^na_kx^k f(x)=xn+1+∑k=

【Hello Python World】Week 2(1):列表简介

1 姓名3-2 问候语3-3 自己的列表3-4 嘉宾名单3-5 修改嘉宾名单3-6 添加嘉宾你刚找到了3-7 缩减名单3-8 放眼世界3-9 晚餐嘉宾3-10 尝试使用各个函数3-11 有意引发错误 第三章主要是介绍Python中的list,比较简单 3.1 姓名 将一些朋友的姓名存储在一个列表中,并将其命名为names 。依次访问该列表中的每个元素,从而将每个朋

【Hello Python World】Class Notes of Week 2

列表 (3.14 update) 1.数组下标错误会抛出异常(与C++不同)2.一个list里可以有不同的数据结构3.插入方法4.删除方法 第一种方法:pop(),有返回值第二种方法:del,没有返回值第三种方法:remove(),没有返回值,而且会抛出异常 5.操作方法 用sort()和sorted()从小到大排序翻转列表reverse()求长度len() 6.列表的数据处理 求和su

【Hello Python World】Week 1(1):探索 展望

什么是Python一些与学习Python有关的网站 wwwpythonorgwwwliaoxuefengcom廖雪峰老师的个人网站 对Python的展望 什么是Python Python的原型诞生于1989年圣诞节,著名的“龟叔”Guido van Rossum在当时为了打发无聊的圣诞假期,随手开发出这款语言。这个有点“无心插柳”的行为却给我们带来了这个简洁而强大工具。时

21—小结(Week)

一 、xutils的框架设计问题,他内部貌似采用的是线程池管理的,当线程池满的时候,其他的线程就会处于等待状态, 这时候如果界面的数据依赖网络请求结果的话,就会造成阻塞状态。 xutils的整个后台是基于ThreadPoolExecutor线程池来做的,该程序封装的线程池的最大连接数是10,所以每次new 一个httpUtils请求下载的时候,一个new 的请求对象最多download下

xamarn.android binding parse sdk for a week to work

Xamarin.Android PackageName 需要设置为项目命名空间且全小写。 http://blog.csdn.net/jameszhou/article/details/41806377

Coursera耶鲁大学金融课程:Financial Markets 笔记Week 02

Financial Markets 本文是学习 https://www.coursera.org/learn/financial-markets-global这门课的学习笔记 这门课的老师是耶鲁大学的Robert Shiller https://en.wikipedia.org/wiki/Robert_J._Shiller Robert James Shiller (born Ma

STAT315 Week 8 广义线性混合模型(GLMMs)

正如我们使用 LMM 对具有相关观测值的正态数据进行建模一样,我们可以使用 GLMM 对非正态分布且具有相关观测值的数据进行建模。 响应变量通常是离散的或明显非正态的。 GLMM 允许响应数据来自指数族的任何其他分布,包括最常见的二项分布和泊松分布。因此,GLMM 是具有正态分布随机效应的广义线性模型。 上图展示了广义线性混合模型(Generalized Linear Mixed Model

MongoDB聚合运算符:$week

MongoDB聚合运算符:$week 文章目录 MongoDB聚合运算符:$week语法使用举例 $week聚合运算符返回指定日期日期为一年中第几周的数字值为0到53之间。周从周日开始,第1周从一年的第一个周日开始。一年中第一个星期日之前的日期为第0周。这和 strftime标准库函数中的 "%U"操作符相同。 语法 { $week: <dateExpression