Created
May 22, 2017 16:14
-
-
Save javalnanda/c1a8d3354bb6c83f41a266f81bc76eb6 to your computer and use it in GitHub Desktop.
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
import Foundation | |
// Enter your code here | |
//print("Enter str1") | |
var str1 = Array(readLine(strippingNewline: true)!.characters) | |
//print("Enter str2") | |
var str2 = Array(readLine(strippingNewline: true)!.characters) | |
var tempDelArr = [Character]() | |
var tempIndexArr = [Int]() | |
func printMinimumCount(_ str1: inout [Character], _ str2: inout [Character]) | |
{ | |
for i in 0..<str1.count { | |
if str2.contains(str1[i]) | |
{ | |
tempIndexArr.append(str2.index(of: str1[i])!) | |
str2.remove(at: str2.index(of: str1[i])!) | |
} | |
else | |
{ | |
tempDelArr.append(str1[i]) | |
} | |
} | |
// result | |
print(tempDelArr.count + str2.count) | |
} | |
if str1.count <= str2.count { | |
printMinimumCount(&str1, &str2) | |
} | |
else { | |
printMinimumCount(&str2, &str1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment