Showing posts with label Puzzle. Show all posts
Showing posts with label Puzzle. Show all posts

March 16, 2018

Josh : playtime with array

Question:Sorted Array have given to you.now a hacker swap odd index value with other odd index value.WAP that serach the element and return it's index in logn complexity.
Example: original sorted  array :{1,2,3,4,5,6,7,8}
              swapped given array:{1,4,3,2,5,8,7,6},key,5(element for searching)
              Output 4(it's index).

April 1, 2015

Vinsol : Defected Meter

Question :A Defected meter is given with missing number 4 from it's rim.WAP that convert the wrong  reading into right one.
Example:
input 100
output 81

March 20, 2015

AMCAT: INACTIVE AND ACTIVE Puzzle solution in C

Question :There are 8 peoples which are standing in a row. They can have two states on a  respective day: Inactive(0) or Active(1). We were given an array of 8 elements which shows the states of these people today and we have to calculate the state of these people after the given no. of days.
Assumption 1: State of person will be Inactive on the next day if both the adjacent persons are having the Active state or Inactive state today.
Assumption 2: State of person will be Active on the next day if one adjacent person is having Active state and other adjacent person is having Inactive state or vice versa.
Assumption 3: Person on the extreme left and extreme right have only one adjacent person, so we can imagine, the other adjacent person is Inactive.
Ex- 1
Input 1: [0,1,1,0,0,1,0,1], 1
Output 1: [1,1,1,1,1,0,0,0]
Ex-2
Input 2: [0,1,0,1,1,0,1,1], 2
Output 2: [0,1,1,1,1,0,1,1]

 /* After day 1, states will be like this [1,0,0,1,1,0,1,1] 

March 19, 2015

Nagarro : Theatre Seat Planing


Question :Write a function for seat allocate and seat reserved.Seat allocate array and seat reserver array.Seat allocate array is of 10*20 and each row and column represent A1 ,A2....;B1 ,B2.....;........J1 ,J2... and so on i.e row are A to J whereas col starts from 0 to 1 9.Each cell in the table represent either 0 or 1 . 0 rep seat available , 1 rep  seat reserved. Seat allocation starts from highest to lowest.And row j is highest, i is second highest and so on.Max 20 seats can be booked at a time. 

if seat is available print the seat no like "B2" i.e (2 row, 3 col)and seat is booked." otherwise Print "Seat is not available."

March 15, 2015

Nagarro:Minimum no of counts from the knight to reach the king?

Question. A chessboard was given to us. Where in there was a Knight and King was placed on certain positions. Our aim is to reach the king from the knight in minimum no of counts.As we know, knight can either move 2 steps vertical/horizontal and 1 step horizontal/vertical. same goes here as well. Proper image of the chess board was given in the question paper, and all the positions(max 8) were given that knight can take in the first step.