## Python / Data Structures

#### Recent solutions:

Check these solutions from our community:
Python / Data Structures DifficultyMedium Python
This program finds the longest word in a list of words.
About this solution: The candidate's solution is correct and uses an optimal approach. The candidate correctly uses the built-in function max() to find the longest word in the list. The candidate also correctly uses a lambda function as the key function to determine the longest word in the list.
Nov 21
Python / Data Structures DifficultyMedium Python
To find the sum of the elements in a list of integers, simply iterate through the list and add each element to a total.
About this solution: This is a good solution that demonstrates a level of completeness and solves the problem. The approach is straightforward and easy to understand.
Nov 21
Python / Data Structures DifficultyMedium Python
Given an array of integers, find the maximum sum of a contiguous subarray. For example, given the array [-2, 1, -3, 4, -1, 2, 1 , -5, 4], the maximum sum of a contiguous subarray is 6 (the sum of the subarray [4, -1, 2, 1]).
About this solution: This is a great solution! The candidate has thought about the problem carefully and has come up with a very elegant solution. The candidate has also provided a clear explanation of how the solution works. Well done!
Nov 20
Python / Data Structures DifficultyMedium Python
This problem asks you to return the sum of all the odd integers in an array. For example, if the input array is [1, 2, 3, 4, 5], the output should be 9.
About this solution: This solution is optimal because it uses a generator expression to filter out the even numbers and then sums the odd numbers. This is optimal because it is a one-liner and it is also very readable.
Nov 19
Python / Data Structures DifficultyMedium Python
Given a list of integers, the largest sum of non-adjacent numbers can be found by writing a function. The function will take the list as input and return the largest sum possible.
About this solution: The candidate's solution is correct and solves the problem. The approach is to use a dynamic programming approach, which is a good approach for this problem. The candidate could have been more concise in their solution, but overall the solution is correct and solves the problem.
Nov 19
Python / Data Structures DifficultyMedium Python
This question is about how to round the values in a dataframe column to the nearest integer. The output should show the rounded values in the column.
About this solution: The candidate's solution is complete and solves the problem. The approach is general and efficient.
Nov 19
Python / Data Structures DifficultyMedium Python
To find the sum of integers in an array, simply iterate through the array and add each integer to a total sum.
About this solution: This solution is complete and solves the problem. The approach is straightforward and easy to understand.
Nov 18
Python / Data Structures DifficultyMedium Python
Given a dataframe, find the row with the maximum value in column 'C' and return the values in columns 'A' and 'B' for that row.