To reward user enthusiasm, Wello has decided to conduct an airdrop for its active users. Ethan, a developer at Wello, has exported a recent transaction log to identify active user addresses.
Each transaction contains:
from: sender wallet addressto: receiver wallet addressamount: transaction amount
A wallet address is considered active if:
- It is involved in at least n transactions (either as sender or receiver)
- The total amount it has sent or received is greater than m
- List of transactions with from, to, and amount
- Two integers:
- n: minimum number of transactions
- m: minimum total amount
- List of wallet addresses that qualify as active users
// input
transactions = [
{ "from": "0xA", "to": "0xB", "amount": 50 },
{ "from": "0xB", "to": "0xC", "amount": 30 },
{ "from": "0xA", "to": "0xC", "amount": 20 },
{ "from": "0xC", "to": "0xA", "amount": 10 },
{ "from": "0xA", "to": "0xB", "amount": 40 }
]
n = 3
m = 60
// output
// Explanation:
// • Address "A" is involved in 4 transactions with a total amount of 120 → qualifies
// • Address "B" is involved in 3 transactions with a total amount of 120 → qualifies
// • Address "C" is involved in 3 transactions, but total amount is 60 → does not qualify (must be greater than m)
["0xA", "0xB"]To optimize system resources, Wello needs to batch transactions together. The challenge is to determine the maximum number of transactions that can be included in a batch while maintaining valid account balances.
Each transaction contains:
from: sender wallet addressto: receiver wallet addressamount: transaction amount
- No address can have a negative net balance after processing transactions
- Net balance = (incoming amounts) - (outgoing amounts)
- List of transactions with from, to, and amount fields
- Maximum number of transactions that can be included while maintaining valid balances
// input
balance = {
"0xA": 9,
"0xB": 10,
"0xC": 11
}
transactions = [
{ "from": "0xA", "to": "0xB", "amount": 10 },
{ "from": "0xB", "to": "0xC", "amount": 5 },
{ "from": "0xC", "to": "0xA", "amount": 5 },
{ "from": "0xA", "to": "0xC", "amount": 15 }
]
// output
3
// Explanation:
// • If we include the first 3 transactions:
// • A: 9 - 10 + 5 = 4
// • B: 10 + 10 - 5 = 15
// • C: 11 + 5 - 5 = 11
// → All balances remain positive
// • Adding the 4th transaction (A -> C 15) would make A's balance -11, which is invalid
// • Therefore, the maximum number of transactions that can be included while maintaining valid balances is 3Design a system that enables merchants to accept stablecoin payments from customers, with features for merchant onboarding, payment processing, and settlement.
- Merchant: Wants to accept stablecoins for their products
- Customer: Pays with stablecoins via their own wallet (e.g. MetaMask, WalletConnect)
- Wello: Provides the payment infrastructure and interfaces
-
Merchant Management
- Merchant onboarding and account creation
- Generate payment requests via API/SDK
- View transaction history and settlements
- Process refunds
-
Payment Processing
- Generate QR codes/payment links for customers
- Support wallet connections (MetaMask, WalletConnect)
- Real-time payment status tracking
- Support multiple stablecoins (e.g. USDC)
-
Blockchain Integration
- Monitor blockchain for incoming transactions
- Validate transaction details (token, amount, sender)
- Track confirmation status
- Smart contract interaction
-
Settlement System
- Record confirmed transactions
- Calculate merchant balances
- Support auto-conversion to fiat
- Manage custody wallets
-
Security & Compliance
- Fraud detection
- Rate limiting
- Transaction monitoring
- KYB/KYC where required