LeetSolve
Published in

LeetSolve

C++ Solution to Coding Challenge 1710. Maximum Units on a Truck

An example of the greedy algorithm

Problem statement

You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxes_i, numberOfUnitsPerBox_i]:

  • numberOfBoxes_i is the number of boxes of type i.

--

--

LeetSolve shares how to solve a coding question in C++. The questions are selected from leetcode.com. You can learn from LeetSolve’s posts essential algorithms, basic data structures, elementary C++ programming language and common coding techniques.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store