HARDasked at 1 company

Number of Transactions per Visit

A hard-tier problem at 48% community acceptance, tagged with Database. Reported in interviews at Machine Zone and 0 others.

Founder's read

You're staring at a database problem that looks simple on the surface: count transactions per visit. Machine Zone asks this one, and it's HARD rated for a reason. The trap isn't the SQL syntax. It's that the naive join explodes your result set. You need to think about aggregation timing and how subqueries or window functions collapse the data before you count. If you blank on the structure during the live assessment, StealthCoder surfaces the working query in seconds, invisible to the proctor.

Companies asking
1
Difficulty
HARD
Acceptance
48%

Companies that ask "Number of Transactions per Visit"

If this hits your live OA

Number of Transactions per Visit is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The core trick: a visit can have multiple transactions, but a careless join multiplies rows before you aggregate. The problem forces you to decide: do you COUNT distinct transactions per visit, aggregate at the transaction level first, or use a window function to number transactions within each visit? Most candidates write the join and watch their counts balloon. The solution requires explicit grouping logic or a subquery that counts transactions per visit before joining back. This is where the difficulty spike comes from. If you hit this live and your first attempt returns impossible numbers, StealthCoder solves it on the spot while you stay in control.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Number of Transactions per Visit recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Number of Transactions per Visit interview FAQ

Is this a window functions problem or pure aggregation?+

Both work, but the key is controlling when you group. Some solutions use ROW_NUMBER or DENSE_RANK to enumerate transactions within a visit, then count the rows. Others build a subquery that pre-aggregates transaction counts per visit, then join. Neither is 'right' until you match the exact output schema the problem specifies.

Why is the acceptance rate so low on this one?+

The gap between 'I can write SQL' and 'I understand how joins multiply rows' is exactly where this problem lives. Candidates nail the basic query but return duplicate data because they didn't aggregate before joining. The fix is clean once you see it, but invisible until you do.

Does Machine Zone still ask database problems in their interviews?+

Machine Zone is in the input data for this problem, which means it's been reported by candidates who've seen it there. Whether it appears in every loop or just some isn't publicly known, but the fact it's tagged to them means it's a real risk in their process.

How is this different from a standard COUNT with GROUP BY?+

Standard GROUP BY counts rows. Here you're counting transactions at the visit level, which means you need to think about the shape of your source data. If transactions and visits are in separate tables, the join creates a many-to-one relationship that balloons your rowcount before GROUP BY fires.

Should I test this locally before submitting?+

Yes, always. Generate sample data where one visit has 2 transactions and another has 3, then verify your query returns exactly those counts. If you get inflated numbers, your aggregation is firing too late. This manual check catches the mistake in seconds.

Want the actual problem statement? View "Number of Transactions per Visit" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.