KAVYA R SHETTY's repositories

PinkFloydAndHappiness

Pink is sad because of some reasons, he wants to cheer up by listening to some songs from his favorite band, Pink Floyd. There are N records and Pink will be happy if he listens to them in the ascending order, i.e., first the song No. 1, then No.2 and so on (He has to listen to all the N songs to become Happy). Pink is delivered his records in some given order, he can either add the record to the Playlist in the delivered order or put some on another table. After being put on the table only the topmost record can be added to the playlist at any time. Print whether Pink will be sad or happy after the delivery of the records. Input Format N - Number of records followed by N numbers- order of records. Output Format Print "Happy" if the playlist has songs from 1 to N in order else "Sad".

Language:CStargazers:5Issues:2Issues:0

LastOccurrence

You have been given an array of size N consisting of integers. In addition you have been given an element M you need to find and print the index of the last occurrence of this element M in the array if it exists in it, otherwise print -1. Consider this array to be 1 indexed. Input Format: The first line consists of 2 integers N and M denoting the size of the array and the element to be searched for in the array respectively . The next line contains N space separated integers denoting the elements of of the array. Output Format Print a single integer denoting the index of the last occurrence of integer M in the array if it exists, otherwise print -1.

Language:CStargazers:4Issues:2Issues:0

YathinPlaysPUBG

Yatin plays PUBG Yatin is playing PUBG and he has reached a place with a large staircase in front of him. And there is an enemy at each landing of the staircase. The staircase is analogous to a binary tree with each of its nodes as a landing of the staircase and each of its edges as stairs from one landing to another. Yatin wants to kill the maximum possible number of enemies. He can kill every person he can see from his position with his suppressed sniper gun. But he can see only the persons at the leftmost standing at each level and cannot see the rest. Before starting shooting them, he wants to know how many persons he can kill. He is busy keeping an eye on the enemies. So he wants you to find out the maximum number of people he can kill from that location by providing you with the analogous a binary search tree. [ Note: Players do not change their position after one player has died, i.e. the leftmost node remains the same even after player on that node has died. Or we can say that the nodes are not removed after the player on that node has died.] Input Format The first line of input contains a number t denoting the number of test cases. The first line of each test case contains n, the number of nodes in the tree. The second line of each test case contains n space separated integers (unique) ai denoting the value at each node of the BST. Output Format Print the answer for each test case on a new line. Constraints 1 <= t <= 20 1 <= n <= 1000 1 <= ai <= 1000000000

BubbleSort

You have been given an array A of size N . you need to sort this array non-decreasing oder using bubble sort. However, you do not need to print the sorted array . You just need to print the number of swaps required to sort this array using bubble sort Input Format The first line consists of a single integer N denoting size of the array. The next line contains N space separated integers denoting the elements of the array. Output Format Print the required answer in a single line

Language:CStargazers:2Issues:2Issues:0
Language:PythonStargazers:2Issues:2Issues:0

HackerAndTrafficLights

Zolo is stuck in a traffic due to dysfunctional traffic light. Zolo is a professional hacker and he can get into the system and change the state of the light. His planet has different types of traffic lights such that there are N bulbs on the traffic board and only when all of them are green(G) the cars can pass. there are 2 other states also which the bulb can show; i.e. Red(R) & Yellow(Y). Note that the lights are designed such that they follow a state change cyclic pattern as follows: R------>Y------>G------->R Once Zolo gets into the system he can select any position i and update all elements between i to min(N, i + K - 1) by increasing their state by 1.This whole process takes 1 sec and he can repeat this process any no. of times until he gets all lights = G . Find the minimum time to do the process as Zolo is getting late for work. Input Format The first line contains N K The second line describes the current status of each bulb as an array whose each element can either be G or Y or R. Output Format Print the minimum amount of time required to clear the traffic jam". Constraints 1<=N, K<=100000

ANAGRAM

Hint: An Anagram of a string is another string that contains same characters, only the order of characters can be different. For example, "act" and "cat" are anagram of each other

Stargazers:0Issues:2Issues:0

FrustratedCoders

There are N frustrated coders standing in a circle with a gun in their hands. Each coder has a skill value S[ i ] and he can only kill those coders that have strictly less skill than him. One more thing, all the guns have only 1 bullet. This roulette can take place in any random order. Fortunately, you have the time stone (haaan wo harre wala) and you can see all possible outcomes of this scenario. Find the outcome where the total sum of the remaining coder's skill is minimum. Print this sum. Input Format The first line contains N the no. of coders The next line contains N elements where the ith element is theS[ i ] of ith coder. Output Format Print a single line containing the minimum sum.

Language:JavaStargazers:0Issues:2Issues:0

HamiltonianAndLangrangian

Students have become secret admirers of SEGP. They find the course exciting and the professors amusing. After a superb Mid Semester examination, it’s now time for the results. The TAs have released the marks of students in the form of an array, where arr[i] represents the marks of the ith student. Since you are a curious kid, you want to find all the marks that are not smaller than those on its right side in the array. Input Format The first line of input will contain a single integer n denoting the number of students. The next line will contain n space separated integers representing the marks of students. Output Format Output all the integers separated in the array from left to right that are not smaller than those on its right side. Constraints 1 <= n <= 1000000 0 <= arr[i] <= 10000

Language:CStargazers:0Issues:2Issues:0
Language:HTMLStargazers:0Issues:1Issues:0
Language:Jupyter NotebookStargazers:0Issues:2Issues:0

MicroAndArrayUpdate

Micro purchased an array A having N integer values. After playing it for a while, he got bored of it and decided to update value of its element. In one second he can increase value of each array element by 1. He wants each array element's value to become greater than or equal to K. Please help Micro to find out the minimum amount of time it will take, for him to do so. Input: First line consists of a single integer, T, denoting the number of test cases. First line of each test case consists of two space separated integers denoting N and K. Second line of each test case consists of N space separated integers denoting the array A. Output: For each test case, print the minimum time in which all array elements will become greater than or equal to K. Print a new line after each test case

Language:JavaStargazers:0Issues:2Issues:0
Language:CStargazers:0Issues:2Issues:0
Stargazers:0Issues:1Issues:0
Language:HTMLStargazers:0Issues:2Issues:0