DataDriven
LearnPracticeInterviewDiscussDailyJobs

The Weight of the Book

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
mid

Problem

An asset-allocation report needs each asset class placed in order of how much money sits in it, where several `holdings` can carry the same `asset_class` and their market values add up. Assign each class a position starting at 1 for the class holding the most total value, and when two classes hold the same total, give the alphabetically earlier name the stronger position. An empty book has nothing to place.

Summary

Every holding pulls its weight. Order the asset classes by what they carry, and let the ties settle by name.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons