Skip to main content

Posts

Showing posts with the label Informatica

LRU Cache [HARD]

Company: Hike, Google, Goldman-Sachs, Flipkart, Expedia, Amazon, Adobe, Walmart-Labs, Ola-Cabs, Microsoft, MakeMyTrip, Intuit, Informatica, Yahoo. Question: The task is to design and implement methods of an  LRU cache . The class has two methods get and set which are defined as follows. get(x)   : Gets the value of the key x if the key exists in the cache otherwise returns -1 set(x,y) : inserts the value if the key x is not already present. If the cache reaches its capacity it should invalidate the least recently used item before inserting the new item. In the constructor of the class the size of the cache should be intitialized.   Input: The first line of input contain an integer T denoting the no of test cases. Then T test case follow. Each test case contains 3 lines. The first line of input contains an integer N denoting the capacity of the cache and then in the next line is an integer Q denoting the no of queries Then Q queries follow. A Query...

Next larger element [EASY]

Company: Snapdeal, Samsung, PayU, Informatica, CouponDunia, Amazon  Question:  Given an array A [ ] having distinct elements, the task is to find the next greater element for each element of the array in order of their appearance in the array. If no such element exists, output -1  Input: The first line of input contains a single integer  T  denoting the number of test cases.Then  T  test cases follow. Each test case consists of two lines. The first line contains an integer N denoting the size of the array. The Second line of each test case contains N space separated positive integers denoting the values/elements in the array A[ ].   Output: For each test case, print in a new line, the next greater element for each array element separated by space in order. Constraints: 1<=T<=200 1<=N<=1000 1<=A[i]<=1000 Example: Input 1 4 1 3 2 4  Output 3 4 4 -1 Explanation In the array, the next larger ...