PhonePe Interview Questions | SSE | DSA Round

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2023-03-17Added By Anonymous
Source:Β Link
🧭 Experience: unknown βœ… Outcome: unknown πŸ’° Compensation: unknown πŸ“ Location: unknown 🏒 Company: PhonePe πŸŽ“ Education: unknown 🎁 Benefits: unknown πŸ“… Offer Date: unknown #### First Problem There are N stocks in the array. Each stock can belong to one of the M categories. The customer wants to form a diversified portfolio by choosing a contiguous subsequence of stocks from that array such that there are exactly C1 count of stocks of category 1, C2 count of stocks of category 2,..., Cm count of stocks of category M. Help your system find the minimum number of stocks to be removed from the array to achieve the contiguous subsequence or return -1 if it’s impossible. Input Format The first line of the input contains n and m (1 ≀ m ≀ n). The second line contains n integers in the range {1, 2, ..., m} representing stocks. The third line contains m integers C1, C2, ..., Cm (with ) – the desired counts of stocks of each category from 1 to m. Sample Input 8 3 3 3 1 2 2 1 1 3 3 1 1 Output 1 (you can remove stock at position 5 with category 2, then you can form subsequence from position 3 to position 8 meeting the requirements) #### Second problem: https://leetcode.com/problems/accounts-merge/
Comments