Codeforces|Leetcode|Codechef free solutions
Open in Telegram
Free codeforces, Codechef, Leetcode solutions are available 😍😍😍😍😍😍 Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. 🥳🥳🥳🤩🤩🤩 Dm @Cpsoln if you want help in coding round.
Show more4 317
Subscribers
No data24 hours
-137 days
-5230 days
Posts Archive
void solve()
{
ll i, j, k, n, m;
cin>>n;
vectorans(2,vll(n));
ll mx=2*n;
ans[0][0]=mx;
ans[1][n-1]=mx-1;
ll front=1,back=mx-2;
for(i=0;i
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define Owner Piyush Kumar
#define loop(o,n) for(int i=o;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define print(a) for(auto &i : a)
#define lower_bound(v,x) lower_bound(v.begin(),v.end(),x)
#define upper_bound(v,x) upper_bound(v.begin(),v.end(),x)
#define pb push_back
const int dx[] = { 0, 1, 0, -1 } ;
const int dy[] = { 1, 0, -1, 0 } ;
int32_t main() {
fast
int t;
cin>>t;
while(t--)
{
int a,b;
cin>>a>>b;
cout<<2<<endl;
cout<<1<<" "<<b-1<<endl;
cout<<a<<" "<<b<<endl;
}
return 0;
}
Today codeforces solution will be free
So share this channel
Minimize Marked Fruits
Python
Trilogy Innovations
def minimize_marked_fruits(A, B, C):
marked = [False] * A
count = 0
for i in range(C):
if not marked[B[i]-1]:
marked[B[i]-1] = True
count += 1
min_count = count
for i in range(C, A):
if not marked[B[i]-1]:
marked[B[i]-1] = True
count += 1
if not marked[B[i-C]-1]:
count -= 1
marked[B[i-C]-1] = False
min_count = min(min_count, count)
return min_count
Minimize Marked Fruits
Python
Trilogy
Good Arrays Code
int n = arr.size();
int A = arr[0];
int B = arr[n-1];
int k = 0;
for (int i = 1; i < n-1; i++) {
if (arr[i] > A) {
k++;
}
}
long long ways = 1;
for (int i = 1; i <= k; i++) {
ways = (ways * i) % 1000000007;
}
return ways;
#include <bits/stdc++.h>
using namespace std;
int count_ways_to_make_array_good(vector<int>& arr) {
int n = arr.size();
int A = arr[0];
int B = arr[n-1];
int k = 0;
for (int i = 1; i < n-1; i++) {
if (arr[i] > A) {
k++;
}
}
long long ways = 1;
for (int i = 1; i <= k; i++) {
ways = (ways * i) % 1000000007;
}
return ways;
}
int main() {
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int ans = count_ways_to_make_array_good(arr);
cout << ans << endl;
return 0;
}
I will upload solutions for free for triology
Please subscribe the channel
