diff --git a/Greedy/DisjointIntervals.cpp b/Greedy/DisjointIntervals.cpp new file mode 100644 index 0000000..ef537fb --- /dev/null +++ b/Greedy/DisjointIntervals.cpp @@ -0,0 +1,16 @@ +// https://www.interviewbit.com/problems/disjoint-intervals/ + +bool sortCol(const vector&a,const vector&b){ + return a[1] > &A) { + sort(A.begin(),A.end(),sortCol); + int count=1,j=0; + for(int i=1;i Solution::solve(vector &a, int b) { + + int n=a.size(); + + vector b1(n+1); + b1[0]=0; + + for(int i=0;i=b) + break; + if(a[i]!=n-i){ + int x=a[b1[n-i]],y=a[i]; + swap(a[i],a[b1[n-i]]); + int k1=b1[x]; + b1[x]=i; + b1[y]=k1; + c++; + } + + } + return a; + +} \ No newline at end of file diff --git a/Greedy/Meetingrooms.cpp b/Greedy/Meetingrooms.cpp new file mode 100644 index 0000000..0951d04 --- /dev/null +++ b/Greedy/Meetingrooms.cpp @@ -0,0 +1,37 @@ +// https://www.interviewbit.com/problems/meeting-rooms/ + +int Solution::solve(vector > &A) { + int n=A.size(); + assert(n>=1 && n<=100000); + for(auto b:A) + for(int a:b) + assert(a>=0 && a<=2000000000); + int start[n]; + int end[n]; + for(int i=0;i