DEV Community

Mukilan Palanichamy
Mukilan Palanichamy

Posted on

My journey in competitive programming

1. Beautiful Arrangement:

Given a number n, arrange the numbers from 1 to n into a sequence where, for every position i (1 based index):

Either i % arr[i] == 0 (position divisible by value)
Or arr[i] % i == 0 (value divisible by position).

Key Points:

  1. This is a backtracking problem where we explore all possible permutations of the numbers 1 to n.
  2. For each position i, we check the divisibility condition and only proceed if it’s satisfied.

Image description

2. Path with Maximum Gold:

You are given a grid of integers where each cell represents the amount of gold at that location. You can move up, down, left, or right, but you cannot revisit a cell or go out of bounds. The task is to find the maximum gold you can collect starting from any cell.

Key Points:

  1. This is a grid-based DFS backtracking problem.
  2. You explore all possible paths starting from each cell, keeping track of the gold collected.
  3. Mark cells as visited during a path and unmark them when backtracking.

Image description

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay