Longest Daily Payment Streak in Indian Standard Time

Last updated: November 29, 2026

Quick Overview

Given a user's transaction timestamps as UTC epoch seconds (unsorted, possibly several per day), return the longest run of consecutive IST calendar days with at least one payment.

PhonePe
Coding & Algorithms
Software Engineer
PhonePe
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given a user's transaction timestamps as UTC epoch seconds (unsorted, possibly several per day), return the longest run of consecutive IST calendar days with at least one payment.

Streak-based rewards (pay on N days in a row to unlock a scratch card) are a common PhonePe engagement mechanic, and the logic must agree with what the user sees on an Indian calendar. The interviewer checks the core set-based streak idea and whether you notice the time zone trap.

What the Interviewer Expects
  • Convert timestamps to IST dates before grouping, not UTC dates
  • Deduplicate days so several payments on one day count once
  • Find runs in linear time with a set instead of sorting when possible
  • Explain the start-of-run trick that keeps the loop O(n)
  • Cover empty input and single-day input
Key Topics to Cover
hash set
date arithmetic
time zones
consecutive runs
rewards logic
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you maintain the current streak incrementally as each payment event arrives?
  • What if a reward rule says a day counts only when a payment is at least Rs 50?
  • How do you handle a payment that later fails or is refunded after the streak was awarded?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: list of integers (UTC epoch seconds). Output: integer, the longest number of consecutive IST calendar days each containing at least one payment. Empty input returns 0. IST is UTC+05:30 and has ...

High-Level Design

Map each timestamp to its IST date and put the dates in a set. A day starts a run only if the previous day is absent; from each run start, walk forward while the next day is present. Each day is visit...


Submit Your Answer
Markdown supported

Related Questions