# Mindtree Solution

Floating Block

```private static int blockNumber(int N) {
List<Integer> list = new ArrayList<>();
for(int i=1;i<=N;i++){
}
while(list.size()>0 && !(list.size() ==1)){
List<Integer> list1 = new ArrayList<>();
for (int i=0; i<list.size(); i = i+2){
}
for (int i=0; i<list1.size(); i = i+2){
list.removeAll(list1);
}
}
return list.get(0);
}```

Dani and Cups Problem

```#include <bits/stdc++.h>
using namespace std;

int main(){
int n,m;
cin>>n>>m;
int arr[n];
int sum = 0;
for(int i=0;i<n;i++) {cin>>arr[i]; sum+=arr[i];}
if(sum < m) cout<<-1;
else{
sort(arr, arr+n);
int x = m/n;
int max = x;
while(max < m){
max = n * x++;
}
cout<<x-1;
}
return 0;
}

```

Cloud server Usage Code

```#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int get_usage(int M, int K, vector<int> usage){

for(int i = 1; i<=M; i++){
sort(usage.begin(),usage.end());
usage[0]++;
}
return usage[K-1];
}
int main(){

int n;
cin>>n;
int m;
cin>>m;
int k;
cin>>k;
vector<int> Arr(n);
for(int i = 0; i<n; i++){
cin>>Arr[i];
}
int result = get_usage(m,k,Arr);
cout<<result<<endl;
return 0;

}```

Average Code

```def average():
sum=0
n=int(input())
p=int(input())
for i in range(n,(n*p+1),n):
sum=sum+i
return int(sum/p)
print(average())```

Vowel Program

```#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {
char a[100],a1[100];
int i,count=0;

scanf("%[^\n]",a);

//https://odewindow.in
for(i=0;i<(strlen(a));i++)
{

if(a[i]=='a' || a[i]=='e' || a[i] == 'i' || a[i]== 'o' || a[i] == 'u')
{
count+=1;

}

}
printf("%d",count);
return 0;
}```

Average Problem

```#include <stdio.h>

int average(int N ,int p) {

int i, ave=0;sum=0;
for(i=1;i<=p;i++){
sum=sum+(i*N);
ave=sum/p;
return ave;
}

}

//https://codewindow.in/
int main(void) {
int N;
scanf("%d",&N);
int p, result;;
scanf("%d",&p);
result=average(N,p);

return 0;
}
```

Guitar strings code.

```//Guitar strings code. Write it inside function line 6

int guitar(int N, vector<int> x){
int ans=0;
//https://codewindow.in/
sort(x.begin(),x.end());
reverse(x.begin(),x.end());
for(int i=0;i<x.size();i++){
ans=ans+x[i]*N;
N-=1;
}
return ans;
}
```

Code in C

```//Write it in the function-

Int blockNum(int N){

int f=log2(n);

int ans =1;
for(int i=0;i<f;i++)
{
ans*=2;
}
return ans;
}
```

Candles Code

```#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/Birthday Cake Candles Code in C/
int main() {
int i;
int n;
int max = 0;
scanf("%d", & n);
int a[n];
int count = 0;
for (i = 1; i <= n; i++) {
scanf("%d", & a[i]);
if (max < a[i])
max = a[i];
}
//https://codewindow.in/
for (i = 1; i <= n; i++)
if (a[i] == max)
count++;
printf("%d", count);
return 0;
}```

Missing KeyBoards

```#include <bits/stdc++.h>
using namespace std;
int missingKeyboards(vector<int> Arr){
int n = Arr.size();
int low = *min_element(Arr.begin(), Arr.end());
int high = *max_element(Arr.begin(), Arr.end());

unordered_set<int> s;
for (int i = 0; i < n; i++)
s.insert(Arr[i]);
int cnt=0;
for (int x = low; x <= high; x++)
if (s.find(x) == s.end())
cnt++;
return cnt;
}
// https::/codewindow.in/
int main()
{
int N;
cin>>N;
vector<int>Arr(N);
for(int i=0;i<N;i++){
cin>>Arr[i];
}
int result = missingKeyboards(Arr);

cout<<result;

return 0;
}
```