-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
78 lines (63 loc) · 2.25 KB
/
Program.cs
File metadata and controls
78 lines (63 loc) · 2.25 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Text;
namespace vowels
{
public class Solution
{
public static string RemoveVowels(string s)
{
StringBuilder result = new StringBuilder();
foreach (char c in s)
{
if (!IsVowel(c))
{
result.Append(c);
}
}
return result.ToString();
}
static bool IsVowel(char c)
{
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ||
c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U';
}
// Inbuilt Functions - Don't Change the below functions
static string ConvertIListToNestedList(IList<IList<int>> input)
{
StringBuilder sb = new StringBuilder();
sb.Append("["); // Add the opening square bracket for the outer list
for (int i = 0; i < input.Count; i++)
{
IList<int> innerList = input[i];
sb.Append("[" + string.Join(",", innerList) + "]");
// Add a comma unless it's the last inner list
if (i < input.Count - 1)
{
sb.Append(",");
}
}
sb.Append("]"); // Add the closing square bracket for the outer list
return sb.ToString();
}
static string ConvertIListToArray(IList<string> input)
{
// Create an array to hold the strings in input
string[] strArray = new string[input.Count];
for (int i = 0; i < input.Count; i++)
{
strArray[i] = "\"" + input[i] + "\""; // Enclose each string in double quotes
}
// Join the strings in strArray with commas and enclose them in square brackets
string result = "[" + string.Join(",", strArray) + "]";
return result;
}
// Main method to demonstrate the usage
public static void Main(string[] args)
{
string inputString = "leetcodeisacommunityforcoders";
string result = RemoveVowels(inputString);
Console.WriteLine(result);
}
}
}