Sequence

[LeetCode] 44. Wildcard Matching 外卡匹配

我们两清 提交于 2020-05-03 22:02:03
Implement wildcard pattern matching with support for '?' and '*' . '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). The function prototype should be: bool isMatch(const char *s, const char *p) Some examples: isMatch("aa","a") → false isMatch("aa","aa") → true isMatch("aaa","aa") → false isMatch("aa", "*") → true isMatch("aa", "a*") → true isMatch("ab", "?*") → true isMatch("aab", "c*a*b") → false 通配符匹配问题,和10. Regular Expression Matching 类似。'?'匹配1个字符,'*'匹配任何字符序列,包括空的

[LeetCode] 936. Stamping The Sequence 戳印序列

╄→гoц情女王★ 提交于 2020-05-03 15:01:14
You want to form a `target` string of lowercase letters. At the beginning, your sequence is target.length '?' marks. You also have a stamp of lowercase letters. On each turn, you may place the stamp over the sequence, and replace every letter in the sequence with the corresponding letter from the stamp. You can make up to 10 * target.length turns. For example, if the initial sequence is "?????", and your stamp is "abc" , then you may make "abc??", "?abc?", "??abc" in the first turn. (Note that the stamp must be fully contained in the boundaries of the sequence in order to stamp.) If the

数据库架构设计的三种模式

北慕城南 提交于 2020-05-02 17:42:24
参考文章: 数据库架构设计的三种模式:share nothing , share everythong , share disk Share-Nothing架构原理 背景介绍 Share nothing理论在数据库设计和优化中的实践应用,首先介绍share nothing概念。最早接触它是在 DataBaseManagentSystem一书的并行数据库章节中。并行数据库要求尽可能的去并行执行数据库操作,从而提高性能。在并行计算体系结构实现中有很多可选的体系结构。 数据库构架设计中主要有Shared Everthting、Shared Nothing、和Shared Disk: Shared Everthting:一般是针对单个主机,完全透明共享CPU/MEMORY/IO,并行处理能力是最差的,典型的代表SQLServer Shared Disk:各个处理单元使用自己的私有 CPU和Memory,共享磁盘系统。典型的代表Oracle Rac, 它是数据共享,可通过增加节点来提高并行处理的能力,扩展能力较好。其类似于SMP(对称多处理)模式,但是当存储器接口达到饱和的时候,增加节点并不能获得更高的性能 。 Shared Nothing:各个处理单元都有自己私有的CPU/内存/硬盘等,不存在共享资源,类似于MPP(大规模并行处理)模式,各处理单元之间通过协议通信,并行处理和扩展能力更好

leetcode 30 days challenge Check If a String Is a Valid Sequence from Root to Leaves Path in a Bi...

半腔热情 提交于 2020-05-02 14:44:48
Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree Given a binary tree where each path going from the root to any leaf form a valid sequence, check if a given string is a valid sequence in such binary tree. We get the given string from the concatenation of an array of integers arr and the concatenation of all values of the nodes along a path results in a sequence in the given binary tree. Example 1: Input: root = [0,1,0,0,1,0,null,null,1,0,0], arr = [0,1,0,1] Output: true Explanation: The path 0 -> 1 -> 0 -> 1 is a valid sequence (green color in the figure). Other

leetcode 30 days challenge Check If a String Is a Valid Sequence from Root to Leaves Path in a Bi...

北城以北 提交于 2020-05-02 14:39:36
Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree Given a binary tree where each path going from the root to any leaf form a valid sequence, check if a given string is a valid sequence in such binary tree. We get the given string from the concatenation of an array of integers arr and the concatenation of all values of the nodes along a path results in a sequence in the given binary tree. Example 1: Input: root = [0,1,0,0,1,0,null,null,1,0,0], arr = [0,1,0,1] Output: true Explanation: The path 0 -> 1 -> 0 -> 1 is a valid sequence (green color in the figure). Other

CF1340F Nastya and CBS

安稳与你 提交于 2020-05-02 12:40:12
原题链接 定义 \(f(S)=去除所有括号珂以匹配的子串后的剩下的字符串\) ,例如: \(f(\) )[]([)]([])[[ \()\) = )([)][[ 。 若 \(S\) 中含有交错的括号序列,如 ([)] ,则称 \(S\) 为WBS(wrong brackets sequence)。 如果字符串 \(S\) 是一个CBS(correct brackets sequence),则 \(f(S)=\operatorname {null}\) 否则,那么 \(f(S)\) 必然会有一下3种情况: \(f(S)\) 是WBS \(f(S)\) 左侧有多余的右括号 \(f(S)\) 右侧有多余的左括号 我们考虑用线段树维护 \(f(S)\) 。 先想想合并两个字符串 \(S_l,S_r\) 需要用到哪些东西 首先要有一个玩意儿来判断 \(S\) 是否是WBS,因为两个WBS合并后也是一个WBS。然后就要处理左右括号的问题。 只有 \(S_r\) 的左边的右括号有珂能和 \(S_l\) 的右边的右括号合并。这要满足 \(S_l\) 的右边的左括号和 \(S_r\) 的左边的右括号的括号类型是相同的。 所以,我们维护线段树上的字符串 \(S\) ,需要用到 \(3\) 个东西: 一个 boolean 值(判断 \(S\) 是否为WBS) 一个字符串 \(l\) ,代表 \(S\)

TCP协议与UDP协议

最后都变了- 提交于 2020-05-02 12:28:50
TCP(Transmission Control Protocol) 传输控制协议 1. 三次握手协议(建立连接) TCP是主机对主机层的传输控制协议,提供可靠的连接服务,采用三次握手确认建立一个连接: 位码即tcp标志位,有6种标示:SYN(synchronous建立联机) ACK(acknowledgement 确认) PSH(push传送) FIN(finish结束) RST(reset重置) URG(urgent紧急) Sequence number(顺序号码) Acknowledge number(确认号码) 第一次握手:主机A发送位码为syn=1,随机产生seq number=1234567的数据包到服务器,主机B由SYN=1知道,A要求建立联机; 第二次握手:主机B收到请求后要确认联机信息,向A发送ack number=(主机A的seq+1),syn=1,ack=1,随机产生seq=7654321的包 第三次握手:主机A收到后检查ack number是否正确,即第一次发送的seq number+1,以及位码ack是否为1,若正确,主机A会再发送ack number=(主机B的seq+1),ack=1,主机B收到后确认seq值与ack=1则连接建立成功。 完成三次握手,主机A与主机B开始传送数据。 2、四次挥手(释放连接) 第一次挥手: 主动关闭方发送一个FIN

【java框架】JPA(2) -- JPA基础

纵然是瞬间 提交于 2020-05-02 09:01:09
1. JPA核心API对象 1.1.Persistence持久化对象 Persisitence主要用于创建EntityMangerFactory,它可以根据传入的持久化单元名称来创建对应的EntityMangerFactory。 // 对应配置文件里面的persistence-unit name="cn.yif.jpa02" // 通过持久化类创建一个实体类管理工厂 EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("cn.yif.jpa02"); 1.2.EntityMangerFactory实体管理工厂 EntityMangerFactory是一个线程安全的对象,在一个项目中只需要一个EntityManger对象,对应一个数据库资源,EntityMangerFactory对象是一个重量级对象,创建与销毁是比较耗费资源的,其中包含了数据库的配置信息,所有实体及关系,预定义JPQL语句、二级缓存。 1.3.EntityManger实体管理对象 EntityManger提供和持久化相关的操作:包括增、删、改、查等,是线程不安全的对象,因此在项目中应该每次只能让一个线程所使用,避免多个线程共享使用。EntityManger是轻量级的,创建与销毁不需要消耗太多的资源

[LeetCode] 186. Reverse Words in a String II 翻转字符串中的单词 II

只谈情不闲聊 提交于 2020-05-02 05:10:36
Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters. The input string does not contain leading or trailing spaces and the words are always separated by a single space. For example, Given s = "the sky is blue", return "blue is sky the". Could you do it in-place without allocating extra space? 151. Reverse Words in a String 一样,这里要求不能用额外空间,要用in-place完成。 该题假设开头和结尾没有空格,而且单词之间只有一个空格。不需要这些假设也是可以的,就是代码会比较复杂。 思路就是两步走,第一步就是将整个字符串翻转。然后从头逐步扫描,将每个遇到单词再翻转过来。 [注意事项] 1)如果是Java,应该跟面试官指出String是immutable,所以需要用char array来做。 2)follow-up问题:k-step reverse

CodeForces

随声附和 提交于 2020-05-02 04:15:13
The sequence of integers a 1 , a 2 , … , a k a1,a2,…,ak is called a good array if a 1 = k − 1 a1=k−1 and a 1 > 0 a1>0. For example, the sequences [ 3 , − 1 , 44 , 0 ] , [ 1 , − 99 ] [3,−1,44,0],[1,−99] are good arrays, and the sequences [ 3 , 7 , 8 ] , [ 2 , 5 , 4 , 1 ] , [ 0 ] [3,7,8],[2,5,4,1],[0] — are not. A sequence of integers is called good if it can be divided into a positive number of good arrays. Each good array should be a subsegment of sequence and each element of the sequence should belong to exactly one array. For example, the sequences [ 2 , − 3 , 0 , 1 , 4 ] [2,−3,0,1,4], [ 1 ,