Visa Interview Question for Staff Engineers
- 0of 0 votes
https://www.hackerrank.com/challenges/array-and-simple-queries- gopal.panda December 03, 2016 in United States
Given two numbers N and M. N indicates the number of elements in the array A(1- indexed) and M indicates number of queries. You need to perform two types of queries on the array A .
You are given M queries. Queries can be of two types, type 1 and type 2.
Type 1 queries are represented as 1 i j : Modify the given array by removing elements from to and adding them to the front.
Type 2 queries are represented as 2 i j : Modify the given array by removing elements from to and adding them to the back.
Your task is to simply print | A - A[N] | of the resulting array after the execution of M queries followed by the resulting array.
Note While adding at back or front the order of elements is preserved.
| Report Duplicate | Flag | PURGE
Visa Staff Engineer Algorithm
Interview Type: Written Test
Open Chat in New Window