#### Category : cp

Challenge Date: 24/7/21 Looking for an Approach Source: Windows Que..

Read more

This was an "easy" leetcode problem to return the number of remaining elements after removing duplicate elements from a sorted set of elements. My code seemed to be removing the last element and its copies altogether and I have not been able to find out why. Can someone please explain/debug? Your input [0,0,1,1,1,2,2,3,3,4] Output [0,1,2,3] ..

Read more

I am a beginner in programming and trying to solve problems from the Australian Informatics Olympiad. I am stuck on this problem even though to me it seems very simple and straight-forward. Here’s the link to the problem: AIO 2020 – Baubles Below is the snippet of my code that only scored 15%: void solve(){ ..

Read more

I want to compute Kth Smallest Element of of A[i]+A[j] (1<i<j<n), but I am getting memory limit exceed for this given problem , how can I overcome this ? Input: The first line of the input contains – the size of the array and . Second-line integers elemnets of array #include<bits/stdc++.h> using namespace std; #define ..

Read more

I want the reduce the time complexity of this code. Input format The first line contains an integer denoting the number of elements in array and . The second line contains space-separated integers denoting the array . The last line contains space-separated integers denoting the array. Inputs and outputs are as given below. Input 5 ..

Read more

https://www.hackerrank.com/challenges/balanced-brackets/problem This is the question link and here is my code : #include <bits/stdc++.h> using namespace std; // Complete the isBalanced function below. string isBalanced(string s) { stack<char> st; for(int i=0;i<(int)s.size();i++) { switch(s[i]) { case ‘(‘ : case ‘{‘ : case ‘[‘ : st.push(s[i]); break; case ‘)’ : **if(st.top()!='(‘ || st.empty())** { return "NO"; } ..

Read more

Following is the code which is running as expected in local ide but when i am submitingh the code in codeforces it is displaying that the outputs are wrong.Question is enter link description heredense array #include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t–) { std::vector<int> my; int x,i,a,j,bno,sno; cin>>x;//enter number of elements ..

Read more

Problem There are N soldiers located on our X-AXIS. The point at which soldier is located also has some number of bombs. The war is near and every soldier wants to communicate with every other soldier. If the ith soldier has b number of bombs and is located at position X then the cost of ..

Read more

I execute the below program on the custom test cases, And it successfully passed the test cases. But while submitting it gives Runtime error: SIGTSTP. #include <bits/stdc++.h> #include<vector> using namespace std; int solve(int arr[], int &n){ int count=1; if(n==1) return count; for(int i=1; i<n; i++){ if(arr[i]<=arr[i-1]){ count++; } } return count; } int main(){ int ..

Read more

Hi someone can help me with cp -r implementation in c? Here is cp implementation: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main(int argc, char **argv) { char buffer[1024]; int files[2]; ssize_t count; if (strcmp("-r",argv[2]) == 0){ //HERE SHOUD BE THE -r implementation } /* Check for insufficient parameters */ if (argc < ..

Read more