# Uncategorized

## [solution] Sleep Technique Solution codechef. Egor came to the Olympiad in Informatics. But the tasks turned out to be too difficult, so Egor chose to sleep instead of solving problems.

….   . Egor came to the Olympiad in Informatics. But the tasks turned out to be too difficult, so Egor chose to sleep instead of solving problems. But as we all know, everyone is very happy when someone is the first who solved the problem. There are NN problems in the contest. The ii-th of them was …

## [solution] Optimal Sorting Solution codechef – Chef gives you a sequence A1,A2,…,ANA1,A2,…,AN consisting of integers. You can perform the following operation on the sequence any number of times (possibly 00

….   .  believes in the optimal usage of all options available. Chef gives you a sequence A1,A2,…,ANA1,A2,…,AN consisting of integers. You can perform the following operation on the sequence any number of times (possibly 00): Select any continuous segment Al…rAl…r and sort the segment in non-descending order, while keeping other elements unchanged. The cost to perform this operation is max(Al…r)−min(Al…r)max(Al…r)−min(Al…r). For example, …

## [solution] Romantic Reversals Solution codechef – Alice initially has a string SS of length NN, and she decides to modify it! Her modification consists of KK steps numbered from 11 to KK.

….Romantic Reversals Solution codechef   ….. Alice initially has a string SS of length NN, and she decides to modify it! Her modification consists of KK steps numbered from 11 to KK. In the ii-th step, Alice reverses the prefix of length ii of SS. For example, suppose Alice starts with S=abfertyS=abferty, and she modifies it via 33 steps, then: After the first step, abferty→S=abfertyabferty→S=abferty After the second step, abferty→S=bafertyabferty→S=baferty After the …

## [solution] Maximum Trio Solution codechef – You are given an array AA of NN elements. For any ordered triplet (i,j,k)(i,j,k) such that ii, jj, and kk are pairwise distinct and 1≤i,j,k≤N1≤i,j,k≤N,

…[solution] Maximum Trio Solution codechef.   .. You are given an array AA of NN elements. For any ordered triplet (i,j,k)(i,j,k) such that ii, jj, and kk are pairwise distinct and 1≤i,j,k≤N1≤i,j,k≤N, the value of this triplet is (Ai−Aj)⋅Ak(Ai−Aj)⋅Ak. You need to find the maximum value among all possible ordered triplets. Note: Two ordered triplets (a,b,c)(a,b,c) and (d,e,f)(d,e,f) are only equal when a=da=d and b=eb=e and c=fc=f. As an example, (1,2,3)(1,2,3) and (2,3,1)(2,3,1) are two different ordered triplets. Input Format The first line …

## [Solution] Maximum Number of Words Found in Sentences solution leetcode

Maximum Number of Words Found in Sentences solution leetcode A sentence is a list of words that are separated by a single space with no leading or trailing spaces.   You are given an array of strings sentences, where each sentences[i] represents a single sentence.   Return the maximum number of words that appear in …