All Posts

Leetcode 1357: Apply Discount Every n Orders

A supermarket offers various products, each with an associated price. The customers make purchases where the subtotal is calculated based on the prices and quantities of the products they buy. Every nth customer gets a discount on their subtotal, and the final bill is calculated accordingly.

Leetcode 1358: Number of Substrings Containing All Three Characters

Given a string s consisting only of characters ‘a’, ‘b’, and ‘c’, your task is to find the number of substrings that contain at least one occurrence of each of the characters ‘a’, ‘b’, and ‘c’.

Leetcode 1366: Rank Teams by Votes

In a special ranking system, each voter assigns a rank to all participating teams in a competition. The rankings are based on the most first-place votes, then second-place votes, and so on. If there is still a tie, teams are ranked alphabetically.

Leetcode 1371: Find the Longest Substring Containing Vowels in Even Counts

Given a string s, find the size of the longest substring containing each vowel (‘a’, ’e’, ‘i’, ‘o’, ‘u’) an even number of times.

Leetcode 1386: Cinema Seat Allocation

A cinema has multiple rows, each with ten seats arranged in a line. Some seats are already reserved. You need to determine the maximum number of four-person groups that can be seated in the available seats. A four-person group requires four adjacent seats in one row. If an aisle splits a group in the middle, they can still be seated if there are two consecutive seats on both sides of the aisle.

Leetcode 1396: Design Underground System

You are tasked with building a system to track customer travel times within an underground railway network. The system should calculate the average time taken to travel between two stations based on previous trips. Implement the UndergroundSystem class with the following methods.