Skip to content

Practice Odd and Even Transactions

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

Medium#3220
LeetCode Problem

Odd and Even Transactions

Problem Statement

Table transactions has transaction_id INT, amount INT, and transaction_date DATE. Group transactions by date and return transaction_date, odd_sum, and even_sum. Parity refers to the amount, not the transaction ID. A missing parity group contributes zero. Sort dates ascending. Practice approach: Use two conditional sums within each date group, testing amount modulo two. Keep ELSE 0 so dates containing only one parity still return both numeric totals. Test an odd ID with an even amount to distinguish the two fields.

Source: Odd and Even Transactions on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
{
  "transactions": [
    {
      "transaction_id": 1,
      "amount": 8,
      "transaction_date": "2026-01-01"
    },
    {
      "transaction_id": 2,
      "amount": 5,
      "transaction_date": "2026-01-01"
    },
    {
      "transaction_id": 3,
      "amount": 6,
      "transaction_date": "2026-01-02"
    }
  ]
}
Output
[
  {
    "transaction_date": "2026-01-01",
    "odd_sum": 5,
    "even_sum": 8
  },
  {
    "transaction_date": "2026-01-02",
    "odd_sum": 0,
    "even_sum": 6
  }
]
Explanation

Amounts 5 and 8 are separated by parity; January 2 has no odd amount, so its odd sum is zero.

Constraints

transaction_id uniquely identifies each transaction.

Related LeetCode Problems

Practice more problems similar to Odd and Even Transactions.

Review your practice with PhantomCodeAI

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