[Logo] Mendo Judge Discussion Board - Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
CodeFights zadaca#1  XML
Forum Index » Други задачи
Author Message
Perez



Joined: 18/10/2014 18:53:59
Messages: 93
Offline

Given an array of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character.

Example

For inputArray = ["aba", "bbb", "bab"], the output should be
stringsRearrangement(inputArray) = false.

All rearrangements don't satisfy the description condition.

For inputArray = ["ab", "bb", "aa"], the output should be
stringsRearrangement(inputArray) = true.

Strings can be rearranged in the following way: "aa", "ab", "bb".
Input/Output

[execution time limit] 0.5 seconds (cpp)

[input] array.string inputArray

A non-empty array of strings of lowercase letters.

Guaranteed constraints:
2 ≤ inputArray.length ≤ 10,
1 ≤ inputArray[i].length ≤ 15.

[output] boolean

Test primeri
input ["aba", "bbb", "bab"] OutPut = false;
input: ["ab", "bb", "aa"] output = true;
input: ["zzzzab", "zzzzbb", "zzzzaa"] output= true;
inputArray: ["ab", "ad", "ef", "eg"] output = false;

Neam idea ... nikakva ...
жучко



Joined: 28/06/2016 17:52:08
Messages: 9
Offline

Neka valid[i][j] e true samo koga stringovite so indexi i i j se razlikuvaat samo vo eden character. Ako gi isprobas site permutacii od indexite na strirngovite togas permutacijata e validno resenie koga za sekoj 2 posledovatelni indexi k1 i k2 od permutacijata valid[k1][k2] e true. Ova resenie e so slozenost O(10!).

This message was edited 2 times. Last update was at 18/08/2018 15:34:08

 
Forum Index » Други задачи
Go to:   
Powered by JForum 2.1.8 © JForum Team