Software Engineer -Backend | Onsite - Interview | PhonePe | Rejected

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-12-06Added By Anonymous
Source: Link
🧭 Experience: unknown ✅ Outcome: Rejected 💰 Compensation: unknown 📍 Location: unknown 🏢 Company: PhonePe 🎓 Education: unknown 🎁 Benefits: unknown 📅 Offer Date: unknown

Q1. We are given a transaction amount N. Due to a bug in the system some digits from N can be dropped resulting in N becoming a lower number(example = 1234 becomes 124 after removing 3). The difference between the number formed after dropping digits and original N is loss for the transaction. Given that we can drop k digits, find maximum loss incurred.

Input: N= 1234, K = 2 Output: 1222 (1234 - 12 after removing 3 and 4)

Suggested brute force using backtracking but could not optimize it. Any pointers on this? Coded the backtracking implementation which failed on one edge case

Q2. Given an array where inc 1 and dec 1 operations are allowed and cost 1 unit for each operation, make all elements equal with minimum cost.

Again, gave brute force and could not come to optimized approach.


Verdict : Rejected
Comments