Skip to main content

Posts

Showing posts with the label codeforces

Avoiding Zero Problem solution Codeforces Global Round 11

Avoiding Zero Problem solution Codeforces Global Round 11- This Problem is taken from codeforces global round 11. This is a very simple problem and strongly recommended to try this problem yourself before jumping to a solution directly.  Link of Problem - https://codeforces.com/contest/1427/problem/A Problem statement-   A. Avoiding Zero time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array of  n n  integers  a 1 , a 2 , … , a n a 1 , a 2 , … , a n . You have to create an array of  n n  integers  b 1 , b 2 , … , b n b 1 , b 2 , … , b n  such that: The array  b b  is a rearrangement of the array  a a , that is, it contains the same values and each value appears the same number of times in the two arrays. In other words, the multisets  { a 1 , a 2 , … , a n } { a 1 , a 2 , … , a n }  and  { b 1 , b 2 , … , b n } { b 1 , b 2 , … , b n }  are equal. For example, if  a = [ 1 , − 1 , 0 , 1 ] a = [ 1 , − 1 , 0