Skip to content

Commit 9605d21

Browse files
committed
Added Solution - GfG to GitHub
1 parent 2c29361 commit 9605d21

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//{ Driver Code Starts
2+
//Initial template for C++
3+
4+
#include<bits/stdc++.h>
5+
using namespace std;
6+
7+
// } Driver Code Ends
8+
// User function Template for C++
9+
10+
class Solution{
11+
public:
12+
int heapHeight(int N, int arr[]){
13+
int count=0,i=0;
14+
while(i<N){
15+
i=2*i+1;
16+
count++;
17+
}
18+
return count-1;
19+
}
20+
};
21+
22+
//{ Driver Code Starts.
23+
24+
int main() {
25+
int t;
26+
cin>>t;
27+
while(t--){
28+
int N;
29+
cin >> N;
30+
int arr[N];
31+
for(int i = 0; i < N; i++)
32+
cin >> arr[i];
33+
34+
Solution ob;
35+
cout << ob.heapHeight(N, arr) << endl;
36+
}
37+
return 0;
38+
}
39+
40+
// } Driver Code Ends

0 commit comments

Comments
 (0)