[LeetCode] Minimize the Total Price of the Trips

2646. Minimize the Total Price of the Trips

There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.

Each node has an associated price. You are given an integer array price, where price[i] is the price of the ith node.

The price sum of a given path is the sum of the prices of all nodes lying on that path.

Additionally, you are given a 2D integer array trips, where trips[i] = [starti, endi] indicates that you start the ith trip from the node starti and travel to the node endi by any path you like.

Before performing your first trip, you can choose some non-adjacent nodes and halve the prices.

Return the minimum total price sum to perform all the given trips.

Read more
[LeetCode] Minimum Additions to Make Valid String

2645. Minimum Additions to Make Valid String

Given a string word to which you can insert letters “a”, “b” or “c” anywhere and any number of times, return the minimum number of letters that must be inserted so that word becomes valid.

A string is called valid if it can be formed by concatenating the string “abc” several times.

Read more
[LeetCode] Find the Maximum Divisibility Score

2644. Find the Maximum Divisibility Score

You are given two 0-indexed integer arrays nums and divisors.

The divisibility score of divisors[i] is the number of indices j such that nums[j] is divisible by divisors[i].

Return the integer divisors[i] with the maximum divisibility score. If there is more than one integer with the maximum score, return the minimum of them.

Read more
[LeetCode] Row With Maximum Ones

2643. Row With Maximum Ones

Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row.

In case there are multiple rows that have the maximum count of ones, the row with the smallest row number should be selected.

Return an array containing the index of the row, and the number of ones in it.

Read more
[Code Jam 2023 Farewell Rounds] Railroad ManagementRead more
[Code Jam 2023 Farewell Rounds] Railroad MaintenanceRead more
[Code Jam 2023 Farewell Rounds] Spacious SetsRead more
[Code Jam 2023 Farewell Rounds] Intruder OutsmartingRead more
[Code Jam 2023 Farewell Rounds] Collecting PancakesRead more
[AtCoder] C - 変わった単位Read more