DumbCarlsen69's blog

By DumbCarlsen69, history, 3 years ago, In English

Hello Everyone, Can anyone clarify when we are using binary search. Sometimes in the while loop We write while(l<r) and sometimes we write while (l<=r) depending from question to question ofc.

But I always get pretty confused between the two and ended up either wasting too much time or making many wrong submissions. is there a clear cut distinction like when we should use the first one and when we should use the second one?

Questions like these confuses me a lot https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/

Thanks!

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By DumbCarlsen69, history, 4 years ago, In English

There is exactly one character ( and exactly one character ) .

This should be There is exactly one character '(' and exactly one character ')'.

I wasted an hour on this :/.

Full text and comments »

  • Vote: I like it
  • +77
  • Vote: I do not like it

By DumbCarlsen69, history, 4 years ago, In English

Anyone know how to come up with these kind of solutions?, because intuitively its not easy and took me a while Thanks!


#include<bits/stdc++.h> using namespace std; #define int long long int32_t main(){ int t; cin>>t; while(t--){ int n,q; cin>>n>>q; int a[n]; for(int i =0; i<n; i++){ cin>>a[i]; } int ans =a[0]; for(int i=1; i<n; i++){ int x = a[i]-a[i-1]; if(x>0){ ans+=x; } else continue; } cout<<ans<<endl; } }

~~~~~

~~~~~

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

By DumbCarlsen69, history, 4 years ago, In English

Hey, So have just started youtube channel, where I will be solving all the contests problems( primarily div2 and div3 ). Will Basically be speaking Hinglish. Here is the link. https://www.youtube.com/channel/UC4o7r8KS9BCt-pt0rR5Yfgg?view_as=subscriber

Thanks!

Full text and comments »

  • Vote: I like it
  • -39
  • Vote: I do not like it