Array List
Array List
int result = 0;
int sum = 0;
sum += nums[i];
result++;
else {
break;
return result;
}
int longestSublist(vector<string>& words) {
// STUDENT ANSWER
int longest = 0;
int current = 0;
current = 1;
} else {
current++;
}
template<class T>
/*
if cap == capacity:
else: do nothing
*/
new_data[i] = data[i];
delete[] data;
data = new_data;
capacity = new_capacity;
}
template <class T>
void ArrayList<T>::add(T e) {
ensureCapacity(count);
data[count] = e;
count++;
template<class T>
/*
if index is invalid:
*/
ensureCapacity(count + 1);
data[index] = e;
count++;
}
template<class T>
int ArrayList<T>::size() {
return count;
}
template<class T>
T ArrayList<T>::removeAt(int index){
/*
if index is invalid:
*/
T removedValue = data[index];
count--;
return removedValue;
template<class T>
/* Remove the first apperance of item in array and return true, otherwise return false */
if (data[i] == item) {
removeAt(i);
return true;
return false;
template<class T>
void ArrayList<T>::clear(){
/*
*/
delete[] data;
capacity = 5;
count = 0;
}
vector<int> updateArrayPerRange(vector<int>& nums, vector<vector<int>>& operations) {
// STUDENT ANSWER
int n = nums.size();
vector<int> result(n);
int L = operation[0];
int R = operation[1];
int X = operation[2];
result[i] += X;
result[i] += nums[i];
}
return result;