+ 3

Dictionary help

I have dictionaries A and B. How to output all values in dictionary A that not contain substrings from dictionary B? https://code.sololearn.com/cmpGloD6UkL5/?ref=app

21st Mar 2019, 7:25 AM
nurkanat amirov
5 Antworten
+ 7
nurkanat amirov I don't know if c# has a built-in function for that, so I would iterate trough dic A and check if value exists in dic b swap keys with values, make domains keys, and then loop through A { if (!B.ContainsKey(key)) { print it or create new array of those that are not in B } {
21st Mar 2019, 11:32 AM
Dejan Dozet
Dejan Dozet - avatar
+ 2
Yes that's right
21st Mar 2019, 11:34 AM
nurkanat amirov
+ 2
But I need the time complexity to be O(N)
21st Mar 2019, 11:35 AM
nurkanat amirov
+ 2
If I iterate through A in B it will be O(N²) time complexity, and there are 1000000 items in each dictionary it will be much time
21st Mar 2019, 11:37 AM
nurkanat amirov
+ 2
Thanks everyone, I've solved the problem with regex. https://code.sololearn.com/chSDAgz7QIor/?ref=app
22nd Mar 2019, 2:40 AM
nurkanat amirov