Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4 Interview Practice: Game Development (20 pt.) Nkumbu is a world-renowed game developer working for Big Corp Studios His game works by randomly generating pets,
4 Interview Practice: Game Development (20 pt.) Nkumbu is a world-renowed game developer working for Big Corp Studios His game works by randomly generating pets, each which costs a random amount of coins (only integer values). The player is then allowed to purchase precisely to pets. Being an awesome developer, Nkumbu wants to make sure that no matter how many coins the player has, there are always two pets that we can purchase at the cost of all his coins 4.1 Finding the Most Expensive Pets (10 pt.) Having been stumped with this problem for quite a bit, he reaches out to Isaiah. whose an avid gamer and recently took COMP 285: Analysis of Algorithms for help. He asks Isaiah to write a C++ function find TwoPets, which takes as input a vector of integers (corresponding to the cost of each pet) as well as a target value corresponding to how many coins the player currently has), and returns a pair that represents two distinct indices of pet costs that sum up to the target value. For some reason, Nkumbu also wants the smaller index to be first. To be super clear, he gives a few examples to Isaiah: std::vector int> pet_costs - 0, 2, 3, 4, 5): std::pair outi - findTwoPets (pet_costs, /coins */6): std::paircint, int> out2- findTwoPets (pet_costs, /coinsto/10); std::cout
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started