A content operations team at Figma needs a script to automate file renaming when duplicate names appear in a batch upload. Given a list of file names in order, return a new list where each name is unique by appending the smallest possible suffix "(k)" to duplicates.
Implement a function that takes a list of strings names and returns a list of strings of the same length. For each name, if it has not appeared before, keep it unchanged. If it already exists, rename it to the smallest available form name(k) where k is a positive integer and the resulting string has not been used earlier.
Example 1
Input: names = ["doc", "doc", "image", "doc(1)", "doc"]
Output: ["doc", "doc(1)", "image", "doc(1)(1)", "doc(2)"]
Explanation: The second "doc" becomes "doc(1)". Later "doc(1)" is already taken, so it becomes "doc(1)(1)". The final "doc" becomes "doc(2)".
Example 2
Input: names = ["a", "a", "a", "a"]
Output: ["a", "a(1)", "a(2)", "a(3)"]
Explanation: Each duplicate gets the next smallest unused suffix.
1 <= len(names) <= 10^51 <= len(names[i]) <= 100names[i] contains printable characters