Created
March 13, 2016 22:00
-
-
Save jianminchen/2909916d9435f69c036b to your computer and use it in GitHub Desktop.
Make it Anagram - using functional programming style - kind of new to Julia
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
class Solution { | |
static void Main(String[] args) { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ | |
var s1 = Console.ReadLine(); | |
var s2 = Console.ReadLine(); | |
var c1 = s1.GroupBy(c => c).ToDictionary(g => g.Key, g => g.Count()); | |
var c2 = s2.GroupBy(c => c).ToDictionary(g => g.Key, g => g.Count()); | |
int res = 0; | |
foreach(var k in c1.Keys) { | |
var diff = c1[k] - (c2.ContainsKey(k) ? c2[k] : 0); | |
res += diff > 0 ? diff : 0; | |
} | |
foreach(var k in c2.Keys) { | |
var diff = c2[k] - (c1.ContainsKey(k) ? c1[k] : 0); | |
res += diff > 0 ? diff : 0; | |
} | |
Console.WriteLine(res); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment