TopCoder 1000Points
来源:互联网 发布:Ubuntu tensorflow gpu 编辑:程序博客网 时间:2024/05/20 19:45
Problem Statement
When editing a single line of text, there are four keys that can be used to move the cursor: end, home, left-arrow and right-arrow. As you would expect, left-arrow and right-arrow move the cursor one character left or one character right, unless the cursor is at the beginning of the line or the end of the line, respectively, in which case the keystrokes do nothing (the cursor does not wrap to the previous or next line). The home key moves the cursor to the beginning of the line, and the end key moves the cursor to the end of the line.You will be given a int, N, representing the number of character in a line of text. The cursor is always between two adjacent characters, at the beginning of the line, or at the end of the line. It starts before the first character, at position 0. The position after the last character on the line is position N. You should simulate a series of keystrokes and return the final position of the cursor. You will be given a String where characters of the String represent the keystrokes made, in order. 'L' and 'R' represent left and right, while 'H' and 'E' represent home and end.
Definition
Class: CursorPosition Method: getPosition Parameters: String, int Returns: int Method signature: int getPosition(String keystrokes, int N) (be sure your method is public)Constraints
- keystrokes will be contain between 1 and 50 'L', 'R', 'H', and 'E' characters, inclusive. - N will be between 1 and 100, inclusive.Examples
0)"ERLLL"
10
Returns: 7First, we go to the end of the line at position 10. Then, the right-arrow does nothing because we are already at the end of the line. Finally, three left-arrows brings us to position 7. 1)
"EHHEEHLLLLRRRRRR"
2
Returns: 2All the right-arrows at the end ensure that we end up at the end of the line. 2)
"ELLLELLRRRRLRLRLLLRLLLRLLLLRLLRRRL"
10
Returns: 33)
"RRLEERLLLLRLLRLRRRLRLRLRLRLLLLL"
19
Returns: 12
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
- TopCoder 1000Points
- TopCoder East China College Tour Round 1 Div 1 1000Points
- TopCoder SRM 144 DIV2 550points
- TopCoder SRM 446 DIV2 500points
- TopCoder SRM 609 DIV2 500points
- topcoder SRM588 DV2 1000
- Topcoder SRM646 DIV2 1000
- TopCoder srm683 div2 1000
- TopCoder
- topcoder
- Topcoder
- topcoder
- topcoder
- Topcoder
- TopCoder 250 points Tournaments 153-TCCC 07 Round 1C DIV 1 78.15/250 31.26%
- TopCoder 300 points 1-SRM 144 DIV 1 90/300 30%
- TopCoder 200 points 2-SRM 144 DIV 2 152.06/200 76.03%
- TopCoder 250 points 3-SRM 145 DIV 1 84.71/250 33.88%
- 一种精确的基于DHT的p2p网络搜索算法与网络拓扑模型
- Runtime.getRuntime().exec()执行本地某一文件
- Jsp标签库--转载
- 小文件的p2p分布式下载算法优化
- 20051124个人日志
- TopCoder 1000Points
- 如何彻底删除Oracle(Windows 2000+ORACLE 8.1.7)
- 国内电子商务的几种典型
- 不使用这个BLOG了...
- 造字
- 福娃系列
- 开始实习了.....
- 试试看!
- 对ajax应用的问题考虑