Lenskart OA/IA

interview experience logo
interview experience
September 12, 2026 · 1 reads

Summary

I completed the Lenskart Initial Assessment consisting of three coding problems. The OA covered activity logs, test execution success rate, and duplicate transaction detection.

Full Experience

Lenskart Initial Assessment

Problem 1: Most Recently Active User per Department

Problem Description

You are given $N$ activity logs representing user activity across different departments. Each record contains a department name, a userId, and an integer timestamp lastSeen.

Your task is to identify the user with the largest lastSeen timestamp for each department.

Rules:

  1. Tie-Breaking Rule: If two or more users in the same department share the exact same maximum lastSeen timestamp, keep the user who appears first in the input order.
  2. Output Order: The output departments must preserve the order of their first appearance in the input data.
  3. Format: Format the result as a single semicolon-delimited string of department=userId pairs (e.g., dept1=u1;dept2=u2).

Examples

Example 1:

Input:

3

eng u1 10

eng u2 20

sales u3 5

Output: "eng=u2;sales=u3"

Explanation:

  • For "eng", u2 has lastSeen = 20, which is greater than u1's 10.
  • For "sales", u3 is the only user with lastSeen = 5.
  • Output maintains the order: "eng" appeared first, then "sales".

Example 2:

Input:

3

eng u1 20

eng u2 20

sales u3 10

Output: "eng=u1;sales=u3"

Explanation:

  • For "eng", both u1 and u2 have lastSeen = 20.
  • Following the tie-breaking rule, u1 is kept because it appeared first in the input.

Constraints

  • $1 \le N \le 10^5$
  • $1 \le$ length of department, userId $\le 50$
  • $0 \le lastSeen \le 10^9$
  • All input records are well-formed space-separated strings.

Problem 2: Test Execution Success Rate

Problem Description

You are given a list of $N$ test execution logs containing string values representing test results ("true", "false", or "null").

Calculate the overall success rate percentage, defined as the total number of "true" entries divided by the total number of valid non-null entries:

$$ \text{Success Rate} = \left( \frac{\text{Count of true results}} {\text{Total non-null results}} \right) \times 100 $$

Rules:

  1. Ignore entries that are equal to "null" (case-insensitive) or empty strings. They should not be counted toward the total valid entries (denominator).
  2. Format the output rounded to 2 decimal places.
  3. If there are no valid non-null entries (i.e., denominator is 0), return 0.00.

Examples

Example 1:

Input:

3

true

true

false

Output: 66.67

Explanation:

  • Total lines N = 3.
  • Valid non-null entries = 3 ("true", "true", "false").
  • True count = 2.
  • Success Rate = (2 / 3) × 100 = 66.666...% → 66.67

Example 2:

Input:

4

true

true

false

null

Output: 66.67

Explanation:

  • Total lines N = 4.
  • "null" entry is ignored from the count.
  • Valid non-null entries = 3.
  • True count = 2.
  • Success Rate = (2 / 3) × 100 = 66.67

Example 3:

Input:

2

null

null

Output: 0.00

Explanation:

  • All entries are "null".
  • Valid non-null count is 0.
  • Output defaults to 0.00 to avoid division by zero.

Constraints

  • $1 \le N \le 10^5$
  • Inputs consist of strings ("true", "false", "null", or empty spaces).
  • Input evaluation is case-insensitive (e.g., "TRUE", "true", and "True" are all treated as "true").

Problem 3: First Duplicate Transaction

Problem Description

You are given a stream of $N$ transaction records processed sequentially. Each transaction is represented by a unique string ID id and an integer timestamp (in minutes), provided in non-decreasing order of timestamps.

A transaction is considered a duplicate if its id has appeared previously in the log with a time difference of 10 minutes or less:

$$ timestamp_{current} - timestamp_{previous} \le 10 $$

Return the id of the first duplicate transaction encountered while scanning in order. If no duplicate transactions exist, return "NONE".


Examples

Example 1:

Input:

3

tx1 0

tx2 1

tx1 5

Output: "tx1"

Explanation:

  • At minute 0, "tx1" appears.
  • At minute 1, "tx2" appears.
  • At minute 5, "tx1" reappears.
  • The gap is 5 - 0 = 5 minutes, which is ≤ 10.
  • "tx1" is the first duplicate transaction found.

Example 2:

Input:

3

tx1 0

tx2 1

tx1 15

Output: "NONE"

Explanation:

  • "tx1" reappears at minute 15.
  • The gap is 15 - 0 = 15 minutes, which is > 10.
  • No valid duplicate transaction is found within 10 minutes.

Constraints

  • $1 \le N \le 10^5$
  • $1 \le$ length of id $\le 50$
  • $0 \le timestamp \le 10^9$
  • Inputs are given in non-decreasing order of timestamps.

I will update this as I proceed to next round. Hope for me to get selected! If any one gave interview in Lenskart please share your experience in comment like OA: DSA,java round1 .....

Interview Questions (3)

1.

Most Recently Active User per Department

Data Structures & Algorithms

Problem Description You are given $N$ activity logs representing user activity across different departments. Each record contains a department name, a userId, and an integer timestamp lastSeen.

Your task is to identify the user with the largest lastSeen timestamp for each department.

Rules

  1. Tie-Breaking Rule: If two or more users in the same department share the exact same maximum lastSeen timestamp, keep the user who appears first in the input order.
  2. Output Order: The output departments must preserve the order of their first appearance in the input data.
  3. Format: Return a semicolon-delimited string of department=userId pairs.

Constraints

  • $1 \le N \le 10^5$
  • $1 \le$ length of department, userId $\le 50$
  • $0 \le lastSeen \le 10^9$
  • All input records are well-formed space-separated strings.
2.

Test Execution Success Rate

Data Structures & Algorithms

Problem Description You are given a list of $N$ test execution logs containing string values representing test results ("true", "false", or "null"). Calculate the overall success rate percentage, defined as the total number of "true" entries divided by the total number of valid non-null entries.

Rules

  1. Ignore entries equal to "null" (case‑insensitive) or empty strings.
  2. Output the result rounded to 2 decimal places.
  3. If there are no valid non‑null entries, return 0.00.

Constraints

  • $1 \le N \le 10^5$
  • Inputs consist of strings ("true", "false", "null", or empty spaces).
  • Case‑insensitive evaluation.
3.

First Duplicate Transaction

Data Structures & Algorithms

Problem Description You are given a stream of $N$ transaction records processed sequentially. Each transaction has a string ID id and an integer timestamp (minutes) in non‑decreasing order.

A transaction is a duplicate if the same id appeared earlier with a time difference of 10 minutes or less:

timestamp_current - timestamp_previous <= 10

Return the id of the first duplicate transaction found, or "NONE" if none exist.

Constraints

  • $1 \le N \le 10^5$
  • $1 \leid length $\le 50$
  • $0 \le timestamp \le 10^9$
  • Input timestamps are non‑decreasing.

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!