Created
March 16, 2017 16:11
-
-
Save sangpt/a7e31f0868859d309f95f4f5493cbdc9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Cho trước 1 xâu. Viết function(tạm gọi là permAlone) liệt kê số các hoán vị của xâu sao cho không có 2 kí tự giống nhau đứng liền kề. | |
Ví dụ permAlone('aab') có các hoán vị (aab, aab, aba, aba, baa, baa) nhưng chỉ có 2 hoán vị đúng yêu cầu là (aba và aba). | |
Dữ liệu mẫu: | |
permAlone("aab") should return a number. | |
permAlone("aab") should return 2. | |
permAlone("aaa") should return 0. | |
permAlone("aabb") should return 8. | |
permAlone("abcdefa") should return 3600. | |
permAlone("abfdefa") should return 2640. | |
permAlone("zzzzzzzz") should return 0. | |
permAlone("a") should return 1. | |
permAlone("aaab") should return 0. | |
permAlone("aaabb") should return 12. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment