CODERE3 - Coder Express 3!!
Mr Durgeshwara was very impressed by Rahul.But now he was in trouble.He has already fixed his daughter's marriage with Thangabali who was the best coder of his town. He got an idea and arranged a contest between Rahul and Thangabali.They have to solve a problem at the same time and whoever solves first will marry Meenamma. Rahul was not such a good coder and was also getting help from Meenamma.Your task is to help Thangabali to solve the problem to create a twist in story .
The problem was that there are large number of builing in the town which are of different heights and all the building are in a single line.
You have to find the maximum possible length of the subsequences of buildings which are possible which are first increasing in heights and then decreasing! Please Note: the heights of the building in the subsequences should be strictly increasing and then strictly decreasing
First line contains an integer T( 1 < = T < = 100) that represents the number of test cases.Then follows the T containg the integer N(1 < = N < = 1000) specifying the total number of elements and the next line contains the N integers A1,A2,A3...An (1<= Ai< = 1000)
For each test case, print only one line, the maximum length of such sequence.
1 3 5 6 4 8 4 3 2 1
8 6 3 4 2 1
for first test case the subsequence is : 1 3 5 6 8 4 3 2 1 for second case it is : 8 6 4 2 1
AC not working in my house.
Nice variation of LIS.
longest bitonic subsequence.. :)
getting WA ANY Tricky cases?
easy one!Last edit: 2017-06-01 13:18:56
easy one . Simple Dynamic Programming problem.
did using O(nlogn) algo AC in 1 go
Try it in O(nlogn) to learn something new ;-)
Solved in one go!!!
nothing new still time limit that bad for python/java.