US001- Editorial

#PROBLEM

Unique Sequence

PROBLEM LINK:

Author: Aman Nadaf
Tester: Aman Nadaf
Editorialist: Aman Nadaf

DIFFICULTY:

Cakewalk

PREREQUISITES:

Linear Search

PROBLEM:

A Unique Sequence is defined as a sequence that do not have any repeating elements in it.
You will be given any random sequence of integers, and you have to tell whether it is a Unique Sequence or not.

EXPLANATION:

Read an array of size n, Traverse through the array and Compare each element with the other using nested for loops .if two elements are same print “ugly” else print “beautiful”.

SOLUTIONS:

Setter's Solution

#include <bits/stdc++.h>
#include <math.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define vi vector
#define vll vector

int main()
{
#ifndef ONLINE_JUDGE
freopen(“in.txt”, “r”, stdin);
freopen(“out.txt”, “w”, stdout);
#endif

std::ios::sync_with_stdio(false);

int t;
cin >> t;
while (t--)
{
  	int n;
	cin>>n;
	int arr[n];
	bool ans = true;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(arr[i] == arr[j]){
				ans = false;
			}
		}
	}
	if(ans == true){
		cout<<"beautiful"<<endl;
	}else{
		cout<<"ugly"<<endl;
	}

}

}

Feel free to share your approach here. Suggestions are always welcomed. :slight_smile: