-
ReverseSubstring
Problem Statement
You are given a string input. You are to find the longest substring of input such that the reversal of the substring is also a substring of input. In case of a tie, return the string that occurs earliest in input.
Definition
Class: ReverseSubstring
Method: findReversed
Parameters: string
Returns: string
Method signature: string findReversed(string input)
(be sure your method is public)
Notes
The substring and its reversal may overlap partially or completely.
The entire original string is itself a valid substring (see example 4).
Constraints
input will contain between 1 and 50 characters, inclusive.
Each character of input will be an uppercase letter ( A - Z ).
Examples
0)
"XBCDEFYWFEDCBZ"
Returns: "BCDEF"
We see that the reverse of BCDEF is FEDCB, which appears later in the string.
1)(Problem Statement You are given a string in put. You are to find the longest substring of proficient ut such that the reversal of the substring is als o a substring of input. In case of a tie. return the string that occurs earliest in input . Definition Class : ReverseSubstring Method : findReversed Parameters : string Returns : Method signature string : string findReversed (string input) (be sure yo ur method is public) The Notes and its substring reversal may overlap partially or completely. The entire original string is itself a valid sub string (see example 4). Constraints will input contain between 1 and 50 characters, inclusive. Each character of input will be an up percase letter (A-Z). Examples 0) "XBCDEFYWFE DCBZ "Returns : "BCDEF" We see the reverse of that is)
- 2007-04-08 00:00:21下载
- 积分:1
-
PLC-VC
使用VC开发的很好的PLC学习平台,能将PLC梯形图编译为指令集。(Desinged by VC for PLC.)
- 2015-11-18 14:34:46下载
- 积分:1
-
简单的贪吃蛇C++源代码
最简单的贪吃蛇C++源代码,可以参考下,初学c或者c++的一个示范例子,简单易懂,可以尝试编程下,开发环境VC6.0都行,里面有注释,方便看懂,仔细敲敲代码,运行下试试看。
- 2022-01-23 10:51:05下载
- 积分:1
-
d4ef13
Z源并网逆变器的间接单周电流控制策略Z source grid-connected inverter single week indirect current control strategy(Z source grid-connected inverter single week indirect current control strategy)
- 2012-02-28 13:05:13下载
- 积分:1
-
shanshuo
数码管闪烁显示0~9,便于初学者理解数码管显示原理,很经典~(Digital tube twinkle show 0 ~ 9, facilitate beginners understand digital pipe display principle, it was a classic ~
)
- 2012-03-12 18:00:17下载
- 积分:1
-
圣者无敌
大通圣者无敌商业服务端全套特此奉献~各位喜欢当年这款游戏的玩家(SOMA GAME SERVER
Dedicated to the players of the game)
- 2021-04-09 14:58:59下载
- 积分:1
-
sh79f084A
中颖SH79F084a 芯片的原厂例程. 内含有定时器,中断,ADC,IO操作. (SOP16.-The Sinowealth SH79F084A chip of the original factory routine. Contains a timer, interrupt,ADC, IO operation. SOP16.)
- 2020-09-24 20:27:48下载
- 积分:1
-
STM32103制作的数控电源源代码
说明: 用STM32103单片机,采用数码管显示电流、电压的数控电源。对学习STM32单片机编程和DIY数控电源很有实用价值。(With STM32103 single chip microcomputer, digital tube is used to display current and voltage. It is very useful for learning STM32 single chip computer programming and DIY numerical control power supply.)
- 2020-03-10 22:21:20下载
- 积分:1
-
word
VC word模板混合编程,在VC中操作word模板,能插入文字和图片(VC word template mixed programming, operation in VC word template, can insert text and pictures)
- 2020-06-29 12:20:02下载
- 积分:1
-
11087 统计逆序对
Description
设a[0…n-1]是一个包含n个数的数组,若在i<j的情况下,有a[i]>a[j],则称(i, j)为a数组的一个逆序对(inversion)。
比如 <2,3,8,6,1> 有5个逆序对。请采用类似“合并排序算法”的分治思路以O(nlogn)的效率来实现逆序对的统计。
一个n个元素序列的逆序对个数由三部分构成:
(1)它的左半部分逆序对的个数,(2)加上右半部分逆序对的个数,(3)再加上左半部分元素大于右半部分元素的数量。
其中前两部分(1)和(2)由递归来实现。要保证算法最后效率O(nlogn),第三部分(3)应该如何实现?
此题请勿采用O(n^2)的简单枚举算法来实现。
并思考如下问题:
(1)怎样的数组含有最多的逆序对?最多的又是多少个呢?
(2)插入排序的运行时间和数组中逆序对的个数有关系吗?什么关系?
输入格式
第一行:n,表示接下来要输入n个元素,n不超过10000。
第二行:n个元素序列。
输出格式
逆序对的个数。
输入样例
5
2 3 8 6 1
输出样例
5(Set a[0... N-1] is a n array containing n numbers. If there is a [i] > a [j] i n the case of I < j, then (i, j) is a n inversion pair of a array.
For example, <2,3,8,6,1> has five reverse pairs. Please use the idea of "merge sorting algorithm" to achieve the statistics of inverse pairs with O (nlogn) efficiency.
The number of inverse pairs of a sequence of n elements consists of three parts:
(1) The number of reverse pairs in the left half, (2) the number of reverse pairs in the right half, (3) the number of elements in the left half is greater than that in the right half.
The first two parts (1) and (2) are implemented by recursion. To ensure the final efficiency of the algorithm O (nlogn), how should the third part (3) be implemented?
Do not use O (n ^ 2) simple enumeration algorithm to solve this problem.)
- 2019-01-07 23:52:06下载
- 积分:1