How To Solve This Atlassian Interview Question?

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-10-17Added By Anonymous
Source:Ā Link
🧭 Experience: unknown āœ… Outcome: unknown šŸ’° Compensation: unknown šŸ“ Location: unknown šŸ¢ Company: Atlassian šŸŽ“ Education: unknown šŸŽ Benefits: unknown šŸ“… Offer Date: unknown

given an array of size n. find no of ways to partition the array into k sub segments such that sum of each segment follows alternative modulo by 2 order. for example : S1 | S2 | S3 | ..... Sk here, s1 denotes sum of segment 1, .. Sk denotes sum of Segment kth now this should follow this order S1%2!=S2%2 , S2%2 !=S3%2... and so on in other words : Sequence of sums should follow this order : EVEN ODD EVEN ODD or : ODD EVEN ODD EVEN return no of ways %1e9+7 note 1<=k<=n 1<=n<=10^5 so i came up with a dp approach, "Decode Ways" like approach, but because n=10^5 it will give TLE
Comments