General Techniques Flashcards
1
Q
What data structure might you use if the problem involves reversing something?
A
Stack
2
Q
How do you use the max() function to find the longest string out of a set of strings?
A
max(str1, str2, key=len)
3
Q
How do you use lambda function in python?
A
list[Object]
list.sort(key=lambda i : i.somePropertyOfObject)
4
Q
What is the difference between sort() and sorted()
A
Sort() sorts the sequence in place and returns nothing.
Sorted() returns a sorted copy of the list without sorting the original.