-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem6.cs
More file actions
49 lines (42 loc) · 1.82 KB
/
Problem6.cs
File metadata and controls
49 lines (42 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Diagnostics;
/// <summary>
/// C# technical interview problem #6
/// </summary>
public static class Problem6
{
/// <summary>
/// Implement a function that, given a string input that contains any combination of the letters A-Z (case insensitive),
/// counts the occurrences of each letter and returns a string representation of the counts in the format "A2B2C3...".
/// The output counts must match the order of first appearance of each letter in the input string. There are multiple solutions
/// to this problem. Pick your favorite.
/// </summary>
public static void CountLettersInString()
{
var input = "AABBAAACCDDDDAAEEEAA";
var expectedOutput = "A2B2A3C2D4A2E3A2";
var result = BuildCountLetters(input);
Debug.Assert(result == expectedOutput, $"Expected '{expectedOutput}' but got '{result}'");
Console.WriteLine(result);
}
/// <summary>
/// Given a string input that contains any combination of the letters A-Z (case insensitive),
/// counts the occurrences of each letter and returns a string representation of the counts in the format "A2B2C3...".
/// The output counts must match the order of first appearance of each letter in the input string. As an example, the input
/// string "AABBAA" would produce the output "A2B2A2".
/// </summary>
/// <example>
/// Input: "AABBAAA"
/// Output: "A2B2A3"
/// </example>
/// <param name="input">
/// The input string. It is expected to be a series of letters from A-Z.
/// </param>
/// <returns>
/// A string representation of the counted letters in the format "A2B2C3...". The comparison is case insensitive.
/// </returns>
static string BuildCountLetters(string input)
{
// TODO: your implementation here
return "";
}
}