Table of Contents 0:00 Problem Statement 0:47 Solution 5:40 Pseudo Code 7:40 Code - Python 8:13 Code - C++
@mathematics33988 күн бұрын
class Solution: def rotateDelete(self, arr): n = len(arr) i = 1 while i < (n//2) + 1: arr.insert(0, arr.pop()) arr.pop(-i) #print(f"{arr} and i={i}") i += 1 return arr[0]
@mathematics33988 күн бұрын
class Solution { public: int rotateDelete(vector &arr) { int i = 1; int n = arr.size(); while (i < (n/2) + 1) { rotate(arr.begin(), arr.end() - 1, arr.end()); arr.erase(arr.begin() + arr.size() - i); i++; } return arr[0]; } };