Skip to content

Practice Investments in 2016

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#585
LeetCode Problem

Investments in 2016

Problem Statement

Tables: Insurance(pid INT, tiv_2015 FLOAT, tiv_2016 FLOAT, lat FLOAT, lon FLOAT). Insurance.pid is unique. tiv_2015 and tiv_2016 are investment amounts for their named years; lat and lon are non-null coordinates. Sum tiv_2016 for policies whose tiv_2015 occurs in at least one other policy and whose (lat, lon) pair occurs in no other policy. Apply both conditions and return the sum as tiv_2016 rounded to two decimals. Coordinate uniqueness concerns the pair, not each coordinate separately.

Source: Investments in 2016 on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
Insurance table: +-----+----------+----------+-----+-----+ | pid | tiv_2015 | tiv_2016 | lat | lon | +-----+----------+----------+-----+-----+ | 1   | 10       | 5        | 10  | 10  | | 2   | 20       | 20       | 20  | 20  | | 3   | 10       | 30       | 20  | 20  | | 4   | 10       | 40       | 40  | 40  | +-----+----------+----------+-----+-----+
Output
+----------+ | tiv_2016 | +----------+ | 45.00    | +----------+

Related LeetCode Problems

Practice more problems similar to Investments in 2016.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.