In this lesson, Alvin explores the strategy to solving the following interview problem:
Write a function, max_value, that takes in a list of numbers as an argument. The function should return the largest number in the list.
Solve this without using any built-in list methods.
You can assume that the list is non-empty.
max_value([4, 7, 2, 8, 10, 9]) # -> 10
max_value([10, 5, 40, 40.3]) # -> 40.3
max_value([-5, -2, -1, -11]) # -> -1
If you need additional support taking these DSA skills and actually applying them, take Alvin's complete data structures and algorithms course on Structy. You can try out the concepts yourself in their interactive code editor and learn advanced DSA patterns like stack exhaustive recursion.
Use this link to get 20% off the entire Structy DSA learning experience.
Follow Alvin on LinkedIn: https://www.linkedin.com/in/alvin-zablan-b73a92117/