Current streak:
1 day
Longest streak:
6 days
Less
More
Very Easy to Understand C++ Solution
#include <bits/stdc++.h>
vector<int> maxOfSubarray(vector<int> nums, int n, int k)
{
vector<int> ans;
for(int i = 0; i<n-k+1; i++){
int Max=INT_MIN;
for(int j = 0; j<k; j++){
Max=max(Max,nums[i+j]);
}
ans.push_back(Max);
}
return ans;
}
select '[0-5>' as bin,
count() as total from sessions where duration >= 0 and duration<300
union
select '[5-10>' as bin,
count(1)as total from sessions where duration >= 300 and duration<600
union
select '[10-15>' as bin,
count(1) as total from sessions where duration >= 600 and duration <900
union
select '15 or more' as bin,
count(1) as total from sessions where duration >= 900
#include <bits/stdc++.h>
void helper(vector<vector<int>>&mat, int i, int j,int m, int n, vector<int>&curr, vector<vector<int>>&v){
curr.push_back(mat[i][j]);
if(i == m-1 and j == n-1){
v.push_back(curr);
curr.pop_back();
return;
}
if(i+1 < m) helper(mat,i+1,j,m,n,curr,v);
if(j+1 < n) helper(mat,i,j+1,m,n,curr,v);
curr.pop_back();
}
vector<vector <int> > printAllpaths(vector<vector<int> > & mat , int m , int n)
{
vector<vector<int>>v;
vector<int> curr;
helper(mat, 0, 0, m, n, curr, v);
return v;
}
#include <bits/stdc++.h>
int partition(vector<int>&arr, int low, int high){
int pivot = arr[high];
int i = low-1;
for(int j = low; j<high; j++){
if(arr[j]<pivot){
i++;
swap(arr[i],arr[j]);
}
}
swap(arr[i+1],arr[high]);
return i+1;
}
void QuickSort(vector<int>&arr,int low, int high){
if(low>high)return;
int pi = partition(arr, low, high);
QuickSort(arr,low,pi-1);
QuickSort(arr,pi+1,high);
}
vector<int> quickSort(vector<int> arr)
{
int n = arr.size();
QuickSort(arr,0,n-1);
return arr;
}
int findMinimumCoins(int amount) { vector<int>ans, currency = {1, 2, 5, 10, 20, 50, 100, 500, 1000}; for(int i = 8; i>= 0; i--){ while(amount >= currency[i]){ amount -= currency[i]; ans.push_back(currency[i]); } } return ans.size(); }