Title Description
There is a shift in the assembly language instruction called a rotate left (the ROL), and now there is a simple task, this instruction is simulated by the string operation result. For a given character sequence S, you put its left circle after K-bit serial output. For example, the character sequence S = "abcXYZdef", rotated left required output result after three, i.e. "XYZdefabc". Is not it simple? OK, get it!
A. Resolve title
The subject borrow a Remove function. Really want is more of a problem.
For example sub-bar. ABC DEF - - DEF ABC (change the top three on the case)
Remove two functions, first removing the top three; after removal of the second three. Finally, I would add to.
II. Code implementation
class Solution { public string LeftRotateString(string str, int n) { // write code here if (n > str.Length || n == 0) { return str; } if (str == null) { return null; } int x = str.Length; string a = str.Remove(0,n); string b = str.Remove(n,str.Length-n); return (a+b); } }