Find permutation in a string (Swift)

func permute(strInput:String,l:Int,r:Int){var inputCharacter = Array(strInput)if ( l==r){print(strInput)}else{for var i in l..<r{// Swapping doneinputCharacter.swapAt(l, i);// Recursion calledpermute(strInput: String(inputCharacter), l: l+1, r: r);//backtrackinputCharacter.swapAt(l, i);}}}

This is how you can use this method:

let str = "ABC
permute(strInput: str, l: 0, r: str.count)

--

--

Mr.Javed Multani

Software Engineer | Certified ScrumMaster® (CSM) | UX Researcher | Youtuber | Tech Writer