반응형

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Question 1.2 | |
/// <summary> | |
/// null 문자로 끝나는 문자열을 뒤집어라. | |
/// </summary> | |
/// <param name="input">입력 문자열</param> | |
/// <returns><paramref name="input"/>이 뒤집어진 문자열</returns> | |
public static string Q2_Reverse(string input) | |
{ | |
System.Text.StringBuilder sb = new System.Text.StringBuilder(); | |
for(int i = input.Length - 1; 0 <= i; i--) | |
{ | |
sb.Append(input[i]); | |
} | |
return sb.ToString(); | |
} | |
#endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void Q1_2() | |
{ | |
Assert.AreEqual(DataStruct.Q2_Reverse("vxyz"), "zyxv"); | |
Assert.AreEqual(DataStruct.Q2_Reverse("abcde"), "edcba"); | |
Assert.AreEqual(DataStruct.Q2_Reverse("cat"), "tac"); | |
} |
반응형
'Develop > 코딩인터뷰' 카테고리의 다른 글
[코딩인터뷰] 문제 1.4 (0) | 2020.04.03 |
---|---|
[코딩인터뷰] 문제 1.3 (0) | 2020.04.03 |
[코딩인터뷰] 문제 1.1 (0) | 2020.04.03 |
[코딩인터뷰] 문제 7.7 (0) | 2020.04.03 |
[코딩인터뷰] 문제 7.6 (0) | 2020.04.03 |
꾸준히 노력하는 개발자 "김예건" 입니다.