-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProgram.cs
More file actions
36 lines (25 loc) · 1016 Bytes
/
Program.cs
File metadata and controls
36 lines (25 loc) · 1016 Bytes
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
using System;
namespace Append_and_Delete {
class Program {
public static string AppendAndDelete(string s, string t, int k) {
if ((s.Length + t.Length) < k) return "Yes";
int minLength = Math.Min(s.Length, t.Length);
int matchingCharacters = 0;
for (int i = 0; i < minLength; i++) {
if (s[i] != t[i]) break;
matchingCharacters++;
}
int minOperations = ((s.Length - matchingCharacters) + (t.Length - matchingCharacters));
if (minOperations == k) return "Yes";
if ((minOperations < k) && ((k - minOperations) % 2 == 0)) return "Yes";
return "No";
}
static void Main(string[] args) {
string s = Console.ReadLine();
string t = Console.ReadLine();
int k = Convert.ToInt32(Console.ReadLine());
string result = AppendAndDelete(s, t, k);
Console.WriteLine(result);
}
}
}