I have a problem we have two string inputs and we want to search that whether these two are equal in terms of rearranging the letters, for e.g- “silent” and “listen” reaaranging them will form the other word. So the output should contain they are equal, but when i write " hi" and “how are you” they shouldn’t be equal , will the logic involve index of the letter? @Palaniyappan@postwick@supermanPunch
Hi @Jai_Pande
Use first six syntax in Assign activity and condition in If.
inputString1= "silent"
inputString2= "listen"
inputString1 = inputString1.Replace(" ", "").ToLower()
inputString2 = inputString2.Replace(" ", "").ToLower()
sortedString1 = New String(inputString1.ToCharArray().OrderBy(Function(c) c).ToArray())
sortedString2 = New String(inputString2.ToCharArray().OrderBy(Function(c) c).ToArray())
If sortedString1 = sortedString2
Then
// The strings are equal when rearranging the letters.
// Add your desired actions here.
LogMessage(“The strings are equal.”)
Else
// The strings are not equal when rearranging the letters.
// Add your desired actions here.
LogMessage(“The strings are not equal.”)
End If
inputString1= "silent"
inputString2= "listen"
inputString1 = inputString1.Replace(" ", "").ToLower()
inputString2 = inputString2.Replace(" ", "").ToLower()
sortedString1 = New String(inputString1.ToCharArray().Sort().ToArray())
sortedString2 = New String(inputString2.ToCharArray().Sort().ToArray())
If sortedString1 = sortedString2
Then
// The strings are equal when rearranging the letters.
// Add your desired actions here.
LogMessage(“The strings are equal.”)
Else
// The strings are not equal when rearranging the letters.
// Add your desired actions here.
LogMessage(“The strings are not equal.”)
End If
One more thing i get it why its converting first to char array so that it can sort individual letters but again why its converting back to array? Please let me know
Thanks alot man! Okay my question was that why in the previous code its written To array in the end of the linq query why we are using to array in the end