Implement the simulateSimpleBrowserBack method that simulates browser back navigation and returns the final page.
The input contains an array pages, its length size, and an integer backs. The array represents browser history in the order the pages were visited.
Your task is to return the page that will be open after pressing the browser back button backs times from the current page. The current page is the last page in the array.
For example, if the history is [home,about,contact] and backs is 1, the browser moves from contact to about.
The current page is located at index size - 1. Each back operation moves one position to the left in the history.
So, subtract backs from the last index to find the final page index. If the number of back operations is greater than the available history, stay at the first page.
After calculating the safe index, return the page stored at that position.
Pseudocode:
function simulateSimpleBrowserBack(pages, size, backs):
if size == 0:
return empty string
index = size - 1 - backs
if index < 0:
index = 0
return pages[index]