## [Solution] Tournament Countdown solution codeforces

Tournament Countdown solution codeforces – There was a tournament consisting of 2đ2nÂ contestants. TheÂ 11-st contestant competed with theÂ 22-nd, theÂ 33-rd competed with theÂ 44-th, and so on. After that, the winner of the first match competed with the winner of second match, etc. The tournament ended when there was only one contestant left, who was declared the winner … Read more

## [Solution] Build Permutation solution codeforces

Build Permutation solution codeforces – A 00-indexedÂ arrayÂ đaÂ of sizeÂ đnÂ is calledÂ goodÂ if for all valid indicesÂ điÂ (0â€đâ€đâ10â€iâ€nâ1),Â đđ+đai+iÂ is a perfect squareâ â . [Solution] Build Permutation solution codeforces Given an integerÂ đn. Find a permutationâĄâĄÂ đpÂ ofÂ [0,1,2,âŠ,đâ1][0,1,2,âŠ,nâ1]Â that is good or determine that no such permutation exists. â â Â An integerÂ đ„xÂ is said to be a perfect square if there exists an integerÂ đŠyÂ such thatÂ đ„=đŠ2x=y2. âĄâĄÂ An arrayÂ đbÂ is a permutation of … Read more

## [Solution] Optimal Reduction solution codeforces

Optimal Reduction solution codeforces – Consider an array đaÂ ofÂ đnÂ positive integers. You may perform the following operation: select two indicesÂ đlÂ andÂ đrÂ (1â€đâ€đâ€đ1â€lâ€râ€n), then decrease all elementsÂ đđ,đđ+1,âŠ,đđal,al+1,âŠ,arÂ byÂ 11. [Solution] Optimal Reduction solution codeforces Let’s callÂ đ(đ)f(a)Â the minimum number of operations needed to change arrayÂ đaÂ into an array ofÂ đnÂ zeros. Determine if for all permutationsâ â Â đbÂ ofÂ đa,Â đ(đ)â€đ(đ)f(a)â€f(b)Â is true. â â Â An arrayÂ đbÂ is a permutation of an arrayÂ đaÂ ifÂ đbÂ consists of … Read more

## [Solution] Traveling Salesman Problem solution codeforces

Traveling Salesman Problem solution codeforces – You are living on an infinite plane with the Cartesian coordinate system on it. In one move you can go to any of the four adjacent points (left, right, up, down). [Solution] Traveling Salesman Problem solution codeforces More formally, if you are standing at the pointÂ (đ„,đŠ)(x,y), you can: go … Read more

## [Solution] Minimum Replacements to Sort the Array solution leetcode

Minimum Replacements to Sort the Array solution leetcode – You are given a 0-indexedÂ integer arrayÂ nums. In one operation you can replace any element of the array withÂ any twoÂ elements thatÂ sumÂ to it. For example, considerÂ nums = [5,6,7]. In one operation, we can replaceÂ nums[1]Â withÂ 2Â andÂ 4Â and convertÂ numsÂ toÂ [5,2,4,7]. [Solution] Minimum Replacements to Sort the Array solution leetcode ReturnÂ the minimum number of … Read more

## [Solution] Task Scheduler II solution leetcode

Task Scheduler II solution leetcode – You are given a 0-indexedÂ array of positive integersÂ tasks, representing tasks that need to be completedÂ in order, whereÂ tasks[i]Â represents theÂ typeÂ of theÂ ithÂ task. [Solution] Task Scheduler II solution leetcode You are also given a positive integerÂ space, which represents theÂ minimumÂ number of days that must passÂ afterÂ the completion of a task before another task of theÂ sameÂ type … Read more

## [Solution] Count Number of Bad Pairs solution leetcode

Count Number of Bad Pairs solution leetcode – You are given a 0-indexedÂ integer arrayÂ nums. A pair of indicesÂ (i, j)Â is aÂ bad pairÂ ifÂ i < jÂ andÂ j – i != nums[j] – nums[i]. [Solution] Count Number of Bad Pairs solution leetcode ReturnÂ the total number ofÂ bad pairsÂ inÂ nums.   Example 1: Input: nums = [4,1,3,3] Output: 5 Explanation: The pair (0, … Read more

## [Solution] Merge Similar Items solution leetcode

Merge Similar Items solution leetcode – You are given two 2D integer arrays, items1Â andÂ items2, representing two sets of items. Each arrayÂ itemsÂ has the following properties: items[i] = [valuei, weighti]Â whereÂ valueiÂ represents theÂ valueÂ andÂ weightiÂ represents theÂ weightÂ of theÂ ithÂ item. The value of each item inÂ itemsÂ isÂ unique. [Solution] Merge Similar Items solution leetcode ReturnÂ a 2D integer arrayÂ retÂ whereÂ ret[i] = [valuei, weighti],Â withÂ weightiÂ being theÂ sum of weightsÂ of all items … Read more

## [Solution] Beautiful Array solution codechef

Beautiful Array solution codechef – You’re given an array AAÂ ofÂ NNÂ integers. You need to find the minimum cost of creating another arrayÂ BBÂ ofÂ NNÂ integers with the following properties [Solution] Beautiful Array solution codechef B_i \ge 0Biââ„0Â for eachÂ 1 \leq i \leq N1â€iâ€N The GCD of adjacent elements ofÂ BBÂ is equal toÂ 11, i.e,Â \gcd(B_i, B_{i+1}) = 1gcd(Biâ,Bi+1â)=1Â for eachÂ 1 \leq i \lt N1â€i<N … Read more

## [Solution] Air Blimp solution codechef

Air Blimp solution codechef – There are NNÂ cities in a row. TheÂ ii-th city from the left has a sadness ofÂ A_iAiâ. In an attempt to reduce the sadness of the cities, you can sendÂ blimpsÂ from the left of cityÂ 11Â that move rightwards (i.e, a blimp crosses citiesÂ 1, 2, \ldots1,2,âŠÂ in order) [Solution] Air Blimp solution codechef You are given … Read more