From 903f8deaf8b84c0bff911ccf7a2e47c1a3d38571 Mon Sep 17 00:00:00 2001 From: ashutosh Date: Sat, 13 Apr 2024 12:57:35 +0530 Subject: [PATCH] chore: solved hard day 8 task --- Hard/Day8/Solution.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/Hard/Day8/Solution.cpp b/Hard/Day8/Solution.cpp index fc13810..5095089 100644 --- a/Hard/Day8/Solution.cpp +++ b/Hard/Day8/Solution.cpp @@ -1 +1,38 @@ -// Write Your Code Here \ No newline at end of file +// Write Your Code Here +#include +using namespace std; +#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); +typedef long long int ll; + +int main() +{ + fast; + int T; cin >> T; + while(T--) + { + ll n,k; cin >> n >> k; + ll a[n]; + for(ll i=0; i> a[i];} + vectorcount(n,0); + ll flag = 0; + + ll start = 0; ll end = n-1; + for(ll i=0; in){flag++; break;} + count[end]++; + ll x = a[end]; + + start = (start-(x%n)); + end = (end-(x%n)); + if(end < 0){end = end+n;} + if(start < 0){start = start+n;} + + ll y = (start+x-1)%n; + if(a[y] != x){flag++; break;} + } + if(flag == 0){cout << "YES" << endl;} + else{cout << "NO" << endl;} + } +} \ No newline at end of file