[Solved] What does this `key=func` part mean in `max(a,b,c,key=func)` in Python?

it allows to define a criterion which replaces the < comparison between elements. For instance: >>>l = [“hhfhfhh”,”xx”,”123455676883″] >>>max(l, key=len) ‘123455676883’ returns the longest string in the list which is “123455676883” Without it, it would return “xx” because it’s the highest ranking string according to string comparison. >>>l = [“hhfhfhh”,”xx”,”123455676883″] >>>max(l) ‘xx’ 2 solved What … Read more

[Solved] Built in function to compare strings in C++?

You could use std::string::compare() which provides the same functionality as strcmp(). std::string name1 = “John”; std::string name2 = “Micheal”; int result = name1.compare(name2); Would roughly be the same as: const char* name1 = “John”; const char* name2 = “Micheal”; int result = std::strcmp(name1, name2); solved Built in function to compare strings in C++?