Java Coding Problem - Merchant Feature Flag Analytics
Context
You are working on a payments platform that supports thousands of merchants.
For each merchant, we can enable or disable a set of product features — such as:
INSTANT_PAYOUTSMULTI_CURRENCYFRAUD_PROTECTIONBETA_DASHBOARDADVANCED_REPORTING
The platform stores feature flags per merchant in a database table:
merchant_id | feature_name | enabled
---------------------------------------------
M101 | INSTANT_PAYOUTS | 1
M101 | FRAUD_PROTECTION | 0
M101 | MULTI_CURRENCY | 1
M101 | BETA_DASHBOARD | 1
M102 | INSTANT_PAYOUTS | 0
...
Where:
enabled = 1→ feature is activeenabled = 0→ feature is inactive
Your task is to build logic that helps the platform understand how many features each merchant has enabled vs disabled.
For a given merchant_id, compute:
Total number of enabled features
Total number of disabled features
(Optional) Return a summary object with the counts
Input
You are given:
class FeatureFlag {
String merchantId;
String featureName;
int enabled; // 1 or 0
}And a method:
List<FeatureFlag> getFeatureFlagsForMerchant(String merchantId);Output
Design a method:
FeatureFlagSummary summarize(String merchantId);Where:
record FeatureFlagSummary(
String merchantId,
int enabledCount,
int disabledCount
) {}Requirements
Count how many feature flags for the merchant have
enabled = 1Count how many feature flags have
enabled = 0Return these counts in a summary object
Example
Input:
Merchant M101 has flags:
[1, 0, 1, 1]
Output:
{
merchantId: “M101”,
enabledCount: 3,
disabledCount: 1
}
📢 Consider becoming a paid subscriber for as low as $2.5/mo (with an annual subscription) and support the work :)
Not convinced? Check out the details of the past work



