is this the most efficient way (in terms of speed) to do this ? or is there any other way ?
Before adding an item to the list you have to initialize it (if the list is not already initialized). Only looking at your description (not code) I can only guess that it is fine. For checking if the key exists, you are using ContainsKey
which has the O(1)
complexity.
what is the time complexity for checking for the key using .ContainsKey()
Dictionary<TKey, TValue>.ContainsKey
Method - MSDN
This method approaches an O(1) operation.