Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 13, 2016 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/2909916d9435f69c036b to your computer and use it in GitHub Desktop.
Save jianminchen/2909916d9435f69c036b to your computer and use it in GitHub Desktop.
Make it Anagram - using functional programming style - kind of new to Julia
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