Hi guys recently gave observe.ai oa for sde-2 position partially solved
3 problems in 75 minutes
if you have optimized solution for each one of the below would love to know your approach
1.Given an array err of n integers. for a triplet of indices i[1],i[2],i[3] (1<=i[1]<=i[2]<=i[3]<=n).
GrossValue(i[1],i[2],i[3])=sum[1,i[1])-sum[i[1],i[2])+sum[i[2],i[3])-sum[i[3],n+1).
Here sum[l, r)(1<=l<=r<=n+1) is the sum of all the
elements in the subarray arr[l,r) i.e
sum[l,r) =(arr[l]+arr[l+1]+---+arr[r-1].
Note that sum[1,1) is 0 as arr[1,1) is an empty subarray.
Find out the maximum gross value of any valid triplet.
Example
arr = [-5, 3, 9, 4]
Some gross value calculations
i[1] i[2] i[3] gross value
2 3 4 -> (-5)-(3)+9-4=-3
1 3 4 -> 0-(-2)+9-4 =7
1 2 5 -> 0-(-5)+16-0=21
row 1--> arr[1,2) - arr[2,3) + arr[3,4) - arr[4,5) is shown.
maximum possible gross value is 21 for indices {1,2,5}
constraints:
1<=n<=3000
-10^9<=arr[i]<=10^9
2.A learner is given a sequential playlist of n videos to enhance their knowledge, implement a function to calculate the minimum time required to complete a total of m viewings while adhering to the platform's constraints.
System Constraints
• Sequential Viewing:
• The learner must watch videos in the order they appear in the playlist.
• To watch a video at index i, the learner must first watch all videos from index O to i-1 at least once.
• Initial Full Viewing:
• To view any video at index i for the first time, the learner must spend firstWatch[i] + repeatWatch[i] minutes. This ensures a complete understanding of the video.
• Subsequent Viewings:
• For subsequent viewings of a video at index i, the learner spends only repeatWatch[i] minutes.
• At any time, they can rewatch any video they have already watched.
• Minimum Total Watch Count:
• The learner must achieve at least m total viewings across all videos.
• Videos can be rewatched as desired, and not all videos need to be watched equally.
Language
Return the minimum time required to complete m viewings of videos while following these constraints.
Example
if n = 4, m = 4, firstWatch = [1, 5, 9. 11], and repeatWatch =
[2, 7, 10, 11], the optimal strategy is as follows:
• The learner watches the Oth video for the first time,
spending firstWatch[O] + repeatWatch[0]= 1 + 2 = 3
minutes.
• The learner then rewatches the Oth video 3 more times
in, spending repeatWatch[0]3 = 23 = 6 minutes.
• The learner has successfully completed 4 viewings.
Thus, the total time required is 3 + 6 = 9 minutes, and
9 is returned.
Constraints
• 1<=n<=10^5
• 1<=m<=10^9
• 1<=firstWatch[i],repeatWatch[i]<=10^9
3.Given n employees, the time when the ith employee starts working is represented by the array startTime[i] and the time when they finish the work is represented by the array endTime[i].
The ith employee can interact with the jth employee if their working hours overlap. A team can only be formed if at least one employee of the team can interact with all other team members. Determine the maximum size of such a team.
Example
n = 5
startTime = [1, 6, 4, 3,1]
endTime = [2, 7, 5, 8, 2].

Consider the group [1, 2, 3]. Employee 3 can interact with other employees in the group, so a team of size 3 is possible. A team with more than 3 employees is impossible. Therefore, the answer is 3.
Constraints:
1<=n<=2*10^5