Practice Making File Names Unique
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i]. Since two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique. Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.
Source: Making File Names Unique on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
names = ["pes","fifa","gta","pes(2019)"]
["pes","fifa","gta","pes(2019)"]
# Example 2
names = ["gta","gta(1)","gta","avalon"]
["gta","gta(1)","gta(2)","avalon"]
# Example 3
names = ["onepiece","onepiece(1)","onepiece(2)","onepiece(3)","onepiece"]
["onepiece","onepiece(1)","onepiece(2)","onepiece(3)","onepiece(4)"]
Constraints
Related LeetCode Problems
Practice more problems similar to Making File Names Unique.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.