General Techniques Flashcards

1
Q

What data structure might you use if the problem involves reversing something?

A

Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you use lambda function in python?

A

list[Object]
list.sort(key=lambda i : i.somePropertyOfObject)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly