Created
March 14, 2016 00:00
-
-
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
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; | |
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