Subject:
Computer ScienceAuthor:
alexvjhdCreated:
1 year agoExplanation:
A teacher has been given a task to select a group of students for a quiz. An array of integers represents a number of students standing in a line and the value at any index represents the intelligence of that student. The teacher can only select a student or a group of students if the total intelligence of students standing consecutively is equal to an integer K. Find how many choices the teacher has to select a group.
Example 1
Input: intelligence = [1,1,1), k= 2
Output: 2
Example 2
Input intelligence = [1,2,3], k = 3
Output: 2
Explanation: The teacher can select either the group of students at 0 and 1 index or student at index 2 alone.
Time Complexity - O(N)
Space Complexity-O(N)
Author:
esdras
Rate an answer:
9