-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathFindDifferenceSln.cs
More file actions
34 lines (32 loc) · 922 Bytes
/
FindDifferenceSln.cs
File metadata and controls
34 lines (32 loc) · 922 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
/* ==============================================================================
* 功能描述:FindDifferenceSln
* 创 建 者:gz
* 创建日期:2017/5/9 13:23:46
* ==============================================================================*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HashTable.Lib
{
/// <summary>
/// FindDifferenceSln
/// </summary>
public class FindDifferenceSln
{
public char FindTheDifference(string s, string t)
{
int[] hash = new int[123]; //97~122
foreach (var ch in s)
hash[Convert.ToInt32(ch)]++;
foreach (var ch in t)
{
int tmp = Convert.ToInt32(ch);
hash[tmp]--;
if (hash[tmp] < 0)
return ch;
}
return ' ';
}
}
}