Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 14, 2016 00: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/0138e2425592638dcf7a to your computer and use it in GitHub Desktop.
Save jianminchen/0138e2425592638dcf7a to your computer and use it in GitHub Desktop.
Make it anagram - using string operation, remove a char from a string - for any char in both two strings
using System;
using System.Collections.Generic;
using System.IO;
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 */
string str1 = Console.ReadLine();
string str2 = Console.ReadLine();
for(int iLoop = 0;iLoop < str1.Length;iLoop++)
{
int indexVal = str2.IndexOf(str1.Substring(iLoop, 1));
if (indexVal >= 0)
{
str2 = str2.Remove(indexVal, 1);
str1 = str1.Remove(iLoop, 1);
iLoop--;
}
}
Console.Write(str2.Length + str1.Length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment