PhonePe OA | On Campus
Anonymous User
226

No. of problems - 4

I don't remember the exact statements, but here's the core idea of each problem.

Problem 1 — Nth Valid Number

You are given a set of hated digits d (digits from 1 to 9).

A positive integer is invalid if any digit in its decimal representation belongs to d.

Find the nth valid positive integer.

Examples

Example 1

d = [5]
n = 5

Valid numbers:
1 2 3 4 6 ...

Answer = 6

Example 2

d = [3, 4]
n = 13

Invalid numbers:
3, 4, 13, 14, 23, 24, ...

Valid numbers:
1 2 5 6 7 8 9 10 11 12 15 16 17 ...

Answer = 17

Constraints

  • 1 <= |d| <= 8
  • Digits are from 1 to 9
  • 1 <= n <= 10^18

Problem 2 — Minimum Cost Path with Latency Constraint

Given:

  • A weighted graph with n nodes (0 to n-1)
  • Edge weights represent latency
  • A cost array, where cost[i] is the cost of visiting node i
  • A source node src
  • A destination node dest
  • A maximum allowed latency L

Find a path such that:

  • Total latency ≤ L
  • Total node cost is minimized
  • The cost of both the source and destination nodes is included

If no such path exists, output -1.


Problem 3 — Two Energy Channels

Initially, there are two channels, each having energy 1.

Each instruction consists of two operations, one for each channel.

Example:

I 3  A 8

where:

  • I x → Increase the channel's energy by x
  • A x → Multiply the channel's energy by x-1

After performing both operations, you may perform one transfer:

  • Transfer the entire energy of either channel to the other.
  • The channel whose energy becomes 0 immediately resets to 1.

Your goal is to maximize the total energy after processing all instructions.


Problem 4 — Tree DP

I don't remember the exact statement because I found it quite confusing.

The only thing I remember is that it was a Tree DP problem with the classic constraint:

You cannot choose both a parent and its child.

It reminded me of LeetCode 337 (House Robber III).


Comments (2)