Category : data-structures

I’m looking for a data structure that supports O(1) random access and worst case O(1) append. In my case however, O(1) amortized time for append is not what I’m looking for. The data structure also will not have any operations performed on it other than append and access. No deletions, no insertions, just an append-only ..

Read more

Question : Find the number of "n"(new line character) present in any string. Input : String s = "Shroud isn a godlike player inn video gaming community." Output : 2 Here is my code : #include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int nseq=0; string s; cin>>s; for(int i=0;i<s.length()-1;i++) { if(s.substr(i,i+1)=="n") { nseq++; ..

Read more

https://cses.fi/problemset/task/1197 Cycle Finding, my algorithm prints cycle if it has any negative weight, but jury is not accepting. they suggested to use bellman ford algorithm but my dfs also working fine. Question: You are given a directed graph, and your task is to find out if it contains a negative cycle, and also give an ..

Read more