[RATS]week-4

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

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

[RATS]week-4

  • Algorithm
    • Question
    • Answer
    • 官方思路
    • Result
  • Review
    • Spring Cloud - Main Projects
  • Tips - MySQL 索引1
  • Share - 软件交付的演进历程 from InfoQ

Algorithm

Question

将一个给定字符串根据给定的行数,以从上往下、从左到右进行 Z 字形排列。
比如输入字符串为 “LEETCODEISHIRING” 行数为 3 时,排列如下:
L C I R
E T O E S I I G
E D H N
之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:“LCIRETOESIIGEDHN”。
请你实现这个将字符串进行指定行数变换的函数:
string convert(string s, int numRows);
示例 1:
输入: s = “LEETCODEISHIRING”, numRows = 3
输出: “LCIRETOESIIGEDHN”
示例 2:
输入: s = “LEETCODEISHIRING”, numRows = 4
输出: “LDREOEIIECIHNTSG”
解释:
L D R
E O E I I
E C I H N
T S G
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/zigzag-conversion
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

Answer

   String[] strArray = s.split("");List<StringBuilder> zList = new ArrayList<>();boolean isTop = false;for (int i = 0; i < strArray.length && i < numRows; i++) {zList.add(new StringBuilder(strArray[i]));}int slantIndex = 2, vIndex = 1;for (int i = numRows; i < strArray.length; i++) {if (isTop) {if (vIndex < numRows - 1) {zList.get(vIndex++).append(strArray[i]);} else {zList.get(zList.size() - 1).append(strArray[i]);isTop = false;vIndex = 1;}} else {int tmpIndex = zList.size() - slantIndex++;if (tmpIndex > 0) {zList.get(tmpIndex).append(strArray[i]);} else {zList.get(0).append(strArray[i]);slantIndex = 2;isTop = true;}}}StringBuilder sbResult = new StringBuilder();for (StringBuilder sb : zList) {sbResult.append(sb);}return sbResult.toString();

官方思路

控制上下游标,到顶则++,到底则–

Result

在这里插入图片描述

Review

Spring Cloud - Main Projects

Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.

Spring CLoud Config 为分布式系统中的外部化的配置文件提供服务器端和客户端的支持。通过配置服务器你有一个集中的地方跨环境的管理应用程序的外部属性。这个该讲同时在客户端和服务端相等的适配Spring环境和抽象属性源,他们不经非常好的适应Spring Application,而且也能被应用在各种语言中各种应用。当通过部署开发环境到测试环境的管线再到生产环境,你可以在这些环境中管理配置文件,并且确定做环境迁移的时候,应用程序拥有运行所需要的一切。这些服务后台存储的默认实现使用git很容易支持打上环境配置的版本标签,也可以访问各种各样的工具来管理内容。添加可替代实现并使用Spring Configuration很轻松的将他们插入其中。

Features
Spring Cloud Config Server features:
HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content)
Encrypt and decrypt property values (symmetric or asymmetric)
Embeddable easily in a Spring Boot application using @EnableConfigServer
Config Client features (for Spring applications):
Bind to the Config Server and initialize Spring Environment with remote property sources
Encrypt and decrypt property values (symmetric or asymmetric)

特性
Spring Cloud Config 服务特性:
Http ,resource-based API针对外部配置文件(name-value对或等价的YAML文件)。
加密和解密属性值(对称和非对称)
使用@EnableConfigServer可以很容易的嵌入一个SpringBoot应用
配置客户端特性(针对Spring Application):
绑定到配置服务并通过远程属性源初始化Spring环境。
加密和解密属性值(对称和非对称)

Getting Started
As long as Spring Boot Actuator and Spring Config Client are on the classpath any Spring Boot application will try to contact a config server on http://localhost:8888, the default value of spring.cloud.config.uri. If you would like to change this default, you can set spring.cloud.config.uri in bootstrap.[yml | properties] or via system properties or environment variables.

只要是Spring Boot 执行器和Spring Config 客户端在类路径下的任何Spring Boot 应用,就可以尝试去关联一个在Http://localhost:8888, 这个默认值是spring.cloud.config.uri。如果想要修改这个默认值,可以通过设置应道程序的spring.cloud.config.uri(yml或 属性文件)或者通过系统属性或环境变量。

@Configuration
@EnableAutoConfiguration
@RestController
public class Application {@Value("${config.name}")String name = "World";@RequestMapping("/")public String home() {return "Hello " + name;}public static void main(String[] args) {SpringApplication.run(Application.class, args);}}

The value of config.name in the sample (or any other values you bind to in the normal Spring Boot way) can come from local configuration or from the remote Config Server. The Config Server will take precedence by default. To see this look at the /env endpoint in the application and see the configServer property sources.
To run your own server use the spring-cloud-config-server dependency and @EnableConfigServer. If you set spring.config.name=configserver the app will run on port 8888 and serve data from a sample repository. You need a spring.cloud.config.server.git.uri to locate the configuration data for your own needs (by default it is the location of a git repository, and can be a local file:… URL).

**
例子中config.name的值(或任何其他值你绑定到常规的SpringBoot)可以来自本地配置文件或者远程配置服务。远程配置服务将默认优先。去看这个look在应用程序的/env下的终结点并且看配置服务的属性源。
为了运行你自己的服务使用spring-cloud-config-server依赖和@EnableConfigServer.如果你设置spring.config.name=configserver,应用程序会运行在8888端口并且使用来自示例仓库的服务数据。为了自己的需求你需要spring.cloud.config.server.git.uri来定位服配置数据(默认的位置是git仓库,也可以是一个本地file)
**

Tips - MySQL 索引1

索引模型:
1.哈希表
Key-value存储数据结构。用一个哈希函数吧key换算成确定的位置上,然后把value放在数组的这个为主。
注意,不同的key经过Hash函数计算会得到同一个值。针对此问题的解决方案,是构建一个链表。
该算法适用于内存数据库及Redis等NoSQL的数据库引擎。
2.有序数组
在等值查询和范围查询场景中的性能就都非常好。但插入操作性能非常差。所以适合静态数据引擎。
3.搜索树
包含2叉树和N叉树(InnoDB)
4.跳表
5.LSM数

InnoDB 中
1.使用B+树(N叉树)的数据结构存储数据,将整棵树的高度位置在很小的范围内。
2.没有主键的表,innodb会默认创建一个RowID作为主键
3.B+树的插入可能会引起数据页的分裂,删除可能会引起数据页的合并,二者都是比较重的IO消耗,所以比较好的方式是顺序插入数据,这也是我们一般使用自增主键的原因之一。
4.在Key-Value的场景下,只有一个索引且是唯一索引,则适合直接使用业务字段作为主键索引。
5.新增数据时,数据是追加的,不会产生叶子节点的分离
6.因为二级索引存放的是主键索引的值,所以主键长度越短所占空间越小4
7.索引类型:
主键索引(聚簇索引):节点存储主键和数据
非主键索引(二级索引):存储非主键索引数据和主键值。
8.使用自增作为主键:append方式追加数据。性能和空间更好
9.一个数据页满了,会新增一个数据页,叫做页分裂,导致性能下降。空间利用率降低大概50%。相邻的两个数据页利用率很低的时候,也做页数据页合并。
10.回表:非主键索引查找到主键,然后再到主键索引查找数据。
11.数据量非常大的时候,非主键索引查找速度大于主键索引。

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

Share - 软件交付的演进历程 from InfoQ

软件交付的演进历程

在这里插入图片描述

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



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

相关文章

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