Skip to content

Conversation

@ErdemT09
Copy link
Collaborator

@ErdemT09 ErdemT09 commented Jul 25, 2021

https://leetcode.com/problems/string-transforms-into-another-string/

Resolves: #239

Algorithm:

A string is not convertible to another string under these 2 conditions:

  1. A character transforms into more than one character:
    "aaa" -> "hgf" is not possible.
  2. The second string contains all possible letters:
    When both strings contain same letters as in: "abc" -> "bca", we can convert individual letters without making them same by temporarily converting them to another letters like this:
    "abc" -> "dbc" -> "dba" -> "dca" -> "bca"
    As long as we have a letter not present in the destination string, we can do such temporary conversions.

We only have to check for these.

Copy link
Collaborator

@altay9 altay9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice code and it is good to see that our names can be converted:

Thank you Erdem.

image

@ErdemT09 ErdemT09 merged commit 1a1cd75 into master Jul 26, 2021
@ErdemT09 ErdemT09 deleted the 1153.-String-Transforms-Into-Another-String branch July 26, 2021 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1153. String Transforms Into Another String

3 participants