Блог пользователя adaptatron

Автор adaptatron, 14 часов назад, По-английски

Given an array, you can select any subarray of length 3, say $$$[a, b, c]$$$. Then, if $$$a + c \gt b$$$, you can delete this triplet, and replace it with $$$(a + c - b)$$$.

Can you achieve an array of length 1 by doing these operations optimally? Then, solve a harder version: How many subarrays can be trimmed to length 1 after doing these operations?

I created a video talking about the ideas and intuition used in this problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

Автор adaptatron, 33 часа назад, По-английски

Count the number of substrings with exactly $$$k$$$ distinct characters. I created a video on this classic 2 Pointer problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор adaptatron, 3 дня назад, По-английски

Given an array, you can reverse any subarray if the minima and maxima of the subarray have different pairities. Can you sort the array after any number of operations?

I created a video discussing the ideas used in this problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор adaptatron, 5 дней назад, По-английски

In an unrooted tree, for a given pair $$$(u, v)$$$, delete all edges on the path from $$$u$$$ to $$$v$$$. Find out the max size of the connected components that are created after this deletion. Call this $$$S$$$.

For each $$$S$$$ in $$$[1, N]$$$, determine how many pairs achieve this $$$S$$$.

I created a video discussing how to solve this problem in $$$O(N^3)$$$ and then optimize it to $$$O(N^2)$$$ by rerooting the tree. Practice Problem

Disclaimer : The intended solution of the linked problem is $$$O(N \cdot Log(N))$$$, but solving it even in $$$O(N^2)$$$ is a good exercise.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор adaptatron, 6 дней назад, По-английски

Given an undirected graph, define the cost of a path as the MEX of all the edge weights on the path. Define $$$dist(u, v)$$$ as minimum possible cost across all paths from $$$u$$$ to $$$v$$$. Practice Problem

  • Compute all pairwise distances.
  • Given a subset of vertices, find the minimum cost to make them connected. Adding an edge $$$(u, v)$$$ costs $$$dist(u, v)$$$.

I created a video talking about how to solve these in $$$O(N^2 \cdot E)$$$ followed by an optimization for $$$O(N \cdot E)$$$.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -12
  • Проголосовать: не нравится

Автор adaptatron, 7 дней назад, По-английски

Given an array, split into the maximum number of blocks such that each block has equal median.

I created a video discussing the ideas used to solve this problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор adaptatron, 8 дней назад, По-английски

Given a string, you have to delete all characters which differ from atleast one of its neighbors (the deletion of all eligible character happen at once).

Find the number of rounds after which deletion is not possible.

I create a video discussing the ideas used in this problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор adaptatron, 9 дней назад, По-английски

Given $$$n$$$ and $$$k$$$, Maximize $$$(a_1 + a_2 + \dots + a_k)$$$ such that $$$a_1 \oplus a_2 \oplus \dots \oplus a_k = n$$$ and $$$0 \leq a_i \leq n$$$.

I created a video discussing the concept of Tight in Bit manipulation and how to apply it to this problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • -14
  • Проголосовать: не нравится

Автор adaptatron, 10 дней назад, По-английски

Partition an array into $$$\geq K$$$ blocks, where each each block has $$$\geq L$$$ elements. Across all such partitions, find the maximum value of the $$$K^{th}$$$ smallest block sum.

I created a video discussing the ideas used to solve this problem. Practice Problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится

Автор adaptatron, 12 дней назад, По-английски

Given an array, you are allowed to select a subarray of size at least $$$k$$$ and delete the $$$k^{th}$$$ smallest element. Can you make the array a palindrome after doing the operation any number of times? Practice Problem

I created a video talking about the ideas used in this problem.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

Автор adaptatron, 2 недели назад, По-английски

I created a video on an interesting problem involving maps, 2 pointer and combinatorics, based on E. Monotonic Renumeration

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор adaptatron, 2 недели назад, По-английски

How many subarrays can be rearranged to form a permutation? I created a video on this classic Codeforces problem F. The Number of Subpermutations

Video Link https://youtu.be/FI__C9WjtvE

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

Автор adaptatron, 2 недели назад, По-английски

I created a video on how to optimize Dynamic Programming problems by using 2 pointers, set, stack, binary search and segment tree. This is based on problem D. Blocking Elements

Video Link: https://youtu.be/f-_1lJo3H_M

Полный текст и комментарии »

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится

Автор adaptatron, 2 недели назад, По-английски

Given an array, split it into $$$k$$$ disjoint consecutive blocks such that the value of $$$\sum a[i] \cdot blockIndex[i]$$$ is maximized.

I created a video discussing why the greedy strategy for this problem is not obvious. Here is the practice problem

https://youtu.be/y_lk5x4ZRNI

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор adaptatron, 2 недели назад, По-английски

I created a video on Greedy algorithms, Combinatorics and Euclid's Divison Lemma. It discusses problem D. Christmas Tree Decoration

Video Link https://youtu.be/b43Bf1syIe4

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор adaptatron, 2 недели назад, По-английски

Given a permutation, compute the unique MEX across all subarrays. Then, reverse the problem, given a binary string where a $$$1$$$ at index $$$i$$$ means that a subarray with MEX $$$i$$$ exists (and $$$0$$$ means it doesn't), compute the number of permutations that satisfy these constraints.

I created a video discussing the ideas to solve both the problem in $$$O(N)$$$. Practice Problem

Video https://youtu.be/78N9JfaQ72g

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

I created a video discussing DP on Trees, Expected Value and Greedy strategies to solve E. Coloring a Red Black Tree from last Codeforces Div2 round.

Video Link: https://youtu.be/EAODhN-zthA

Полный текст и комментарии »

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

Given an array, compute the prefix maxima array and remove all the duplicates. How many subsequences of the original array can you create such that the prefix maxima of the subsequence is equal to the prefix maxima of the original array (after removing the duplicates from both)?

I created a video to solve this problem in $$$O(N \cdot Log(N))$$$.

https://youtu.be/3VQtW8lnEvQ

Practice Problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

I created a video brainstorming problem C. Interval Mod from today's Codeforces Div2 round. It discusses some ideas that you can apply on problems that involve operations on a subarray.

Video Link: https://youtu.be/nZ5U43GGlyc

Полный текст и комментарии »

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

I created a video that talks about some bit manipulation tricks, and how to apply horner's trick to binary search the starting element that produces a geometric series sum. This is also the editorial for D. RReeppeettiittiioonn from today's Codeforces round.

Video https://youtu.be/4MsjyCriVGU

Полный текст и комментарии »

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

Everyone knows the classical Dynamic Programming problem of finding the max profit path in a grid. But can you quickly find out the maximum profit when I change an arbitrary cell's value? I discuss an anti diagonal trick that can be used to solve such problems. This idea appeared in a recent Div 2 contest, E. The Turtle Strikes Back

Video https://youtu.be/ms8douXze4E

Полный текст и комментарии »

  • Проголосовать: нравится
  • +13
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

I created a video talking about Dynamic Programming on Trees in context of problem H. Closer from last Div2 round. It also talks about why iterating over all the grandchildren is actually $$$O(N^2)$$$ instead of $$$O(N^3)$$$.

Video Link: https://youtu.be/9opfwMW0wWw

Полный текст и комментарии »

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

Problem G. Down the Pivot had an interesting subproblem, given a tree where nodes contain 0 or 1, in one operation, you are allowed to select one downward path and flip it. What is the minimum number of operations required to set all nodes to 0?

So I created a video discussing 3 techniques:

  • Minimum operations when you are allowed to flip a subarray.
  • Minimum operations when you are allowed to flip a subtree.
  • Minimum operations when you are allowed to flip a downward path.

https://youtu.be/ekhPwtSgY_g

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

In continuation of my last video, where we talked about a problem that transitioned from Game theory to Bitmask DP, I uploaded a video that talks about the transition from bitmask to Combinatorics (which is essentially the hard version of the previous problem).

Video https://youtu.be/O-zszo57B54

Practice Problem: E2. Prime Gaming (Hard Version)

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор adaptatron, 3 недели назад, По-английски

I created a video on a game theory problem that can be solved via Bitmask DP and Minimax DP.

Video Link : https://youtu.be/tSJgBJkfT94

Practice Problem: Easy Version and Hard Version

Полный текст и комментарии »

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится