Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun main(args: Array<String>) {
- /*
- re-arrange to key/pairs of original to match target
- make sure no value is assigned to two keys in original at the same time.
- You'd start with swapping original[2] with with placeholdingChar, such that placeholdingChar is now 'a'.
- Then you'd lookup 'target' to see at which index 'a' belongs. Then you'd swap the value of that index in
- 'original' with 'a', and lookup target to see where that belongs.
- Proceed until all values are with their correct key.
- */
- }
- var placeholdingChar = "f"
- val original = mutableMapOf(1 to "c",
- 2 to "d",
- 3 to "a",
- 4 to "e",
- 5 to "b")
- val target = mapOf(1 to "a",
- 2 to "b",
- 3 to "c",
- 4 to "d",
- 5 to "e")
Advertisement
Add Comment
Please, Sign In to add comment