Total Tyres Calculation

Quick Overview

Given a list of dealerships, each holding a count of cars and bikes, return the total number of tyres when every car has 4 and every bike has 2. It is a warm-up array problem that tests a clean single pass, the summation identity and awareness of integer overflow.

Total Tyres Calculation

Company: Sap

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

You are given a list of dealerships, where each dealership is represented as a pair `[cars, bikes]` indicating the number of cars and bikes at that dealership. Each car has `4` tyres and each bike has `2` tyres. Return the total number of tyres across all dealerships. ### Function Signature ```python def total_tyres(dealerships: list[list[int]]) -> int: ``` ### Rules - Each dealership is a list of exactly two non-negative integers in the order `[cars, bikes]`. - Return the total as a single integer. ### Constraints - `1 <= len(dealerships) <= 10^4` - `0 <= cars, bikes <= 10^5` ### Examples ```text Input: dealerships = [[3,5],[2,10],[0,4]] Output: 58 ``` Dealership 1 has 3 * 4 + 5 * 2 = 22 tyres, dealership 2 has 2 * 4 + 10 * 2 = 28 and dealership 3 has 0 * 4 + 4 * 2 = 8. The total is 22 + 28 + 8 = 58. ```text Input: dealerships = [[1,1]] Output: 6 ``` One car and one bike give 1 * 4 + 1 * 2 = 6 tyres.

Overview: Given a list of dealerships, each holding a count of cars and bikes, return the total number of tyres when every car has 4 and every bike has 2. It is a warm-up array problem that tests a clean single pass, the summation identity and awareness of integer overflow.

Sap logo
Sap
Nov 24, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

You are given a list of dealerships, where each dealership is represented as a pair [cars, bikes] indicating the number of cars and bikes at that dealership.

Each car has 4 tyres and each bike has 2 tyres. Return the total number of tyres across all dealerships.

Function Signature

def total_tyres(dealerships: list[list[int]]) -> int:

Rules

  • Each dealership is a list of exactly two non-negative integers in the order [cars, bikes] .
  • Return the total as a single integer.

Constraints

  • 1 <= len(dealerships) <= 10^4
  • 0 <= cars, bikes <= 10^5

Examples

Input: dealerships = [[3,5],[2,10],[0,4]]
Output: 58

Dealership 1 has 3 * 4 + 5 * 2 = 22 tyres, dealership 2 has 2 * 4 + 10 * 2 = 28 and dealership 3 has 0 * 4 + 4 * 2 = 8. The total is 22 + 28 + 8 = 58.

Input: dealerships = [[1,1]]
Output: 6

One car and one bike give 1 * 4 + 1 * 2 = 6 tyres.