Convert Set to List without creating new List

You can use the List.addAll() method. It accepts a Collection as an argument, and your set is a Collection. EDIT: as respond to the edit of the question.It is easy to see that if you want to have a Map with Lists as values, in order to have k different values, you need to create k different lists.Thus: You cannot avoid … Read more

what does O(N) mean [duplicate]

The comment was referring to the Big-O Notation. Briefly: O(1) means in constant time – independent of the number of items. O(N) means in proportion to the number of items. O(log N) means a time proportional to log(N) Basically any ‘O’ notation means an operation will take time up to a maximum of k*f(N)where: k is a … Read more