Min no of +1 operations on array to have only k distinct elements
№ | Пользователь | Рейтинг |
---|---|---|
1 | ecnerwala | 3649 |
2 | Benq | 3581 |
3 | orzdevinwang | 3570 |
4 | Geothermal | 3569 |
4 | cnnfls_csy | 3569 |
6 | tourist | 3565 |
7 | maroonrk | 3531 |
8 | Radewoosh | 3521 |
9 | Um_nik | 3482 |
10 | jiangly | 3468 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 163 |
4 | TheScrasse | 159 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 151 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
Min no of +1 operations on array to have only k distinct elements
The ememy of your ememy is friend.Given Q queries of form:
1 person1 person2
2 0 person
person is signified using id
your id is 0
for query of type 2 print following:
-1 if person is your enemy
1 if person is your friend
0 if person is not related to you
A person is your friend if he is:
enemy of your enemy
enemy of your's friend enemy and so on
constraints : 0<id<10^5 0<Q<10^5
example:
1 1 2
1 0 1
1 3 4
2 0 1
2 0 2
2 0 4
output:
-1
1
0
Given two binary strings of equal length (eg. "10101" and "10010") we had to find whether we can convert string 1 to string 2 by performing following operations:
reverse substring of length 2 reverse substring of length 2 reverse substring of length 2
Given a range [l r] find the sum of last digits of fibonacci numbers between l and r. i.e , last(fib(l))+last(fib(l+1)) .... last(fib(r)),
where last(fib(a)) denotes last digit of ath fibonacci number.
1<=l<=r<=1e9
Given an array, choose two contiguous non-overlapping arrays, such that all elements are strictly increasing. Return the maximum length possible for this combination.
Ex: 7 1 2 4 6 5 3 8 9 10 => ans: 7 (Choose 1 2 4 6 & 8 9 10)
given a number n, convert it into k such that k has all even digit with minimum no of operations. 1 operation is either increment or decrement n by 1.
example: Input 11 output -> 3 Input 199 output -> 1 Input 2018 output -> 2
what will happen if i run kruskal algorithm on disconected graph?? Actual problem is given n disconnected undirected graphs find kth largest value of mst of all graphs
You are working in Samara, Russia for a few days. Each day has a new pay per unit of work and a new cost per unit of food. Working 1 unit costs 1 unit of energy, and eating 1 unit of food adds 1 unit of energy. Here are some specifications of your employment:
You arrive with no money, but with energy. You can never have more energy than you arrive with, and it can never be negative. You can do any amount of work every day (possibly not do any work at all), limited only by your energy. You cannot work when your energy is zero. You can eat any amount of food every day (possibly not have any food at all), limited by the money you have. You cannot eat when the money you have is zero. You can eat food at the end of the day, and cannot return to work after eating. You can return to work the next day. Your true goal is to return home with as much money as possible. Compute the maximum amount of money you can take home.
Input: N = 3, Earning=[1, 2, 4], Cost[]=[1, 3, 6], E = 5 Output: 20
Help needed to solve this problem. It was asked in an online assessment of a company. Here is the link:- [https://stackoverflow.com/questions/63972021/what-is-the-algorithm-for-this-programming-question]
How to count total no. of distinct cycles in an undirected graph. Graph may be disconnected. Constraints: 0<= no. of nodes <=10
Answer for given image is 7
You Are given an array A of N integers. You have to answer Q queries of form L R. Answer to each query is sum of lengths of all sub arrays in A whose maximum element lies in range [L,R].
Constraints:
1<=N,Q<=3*10^5 1<=A[i]<=10^9 1<=L<=R<=10^9
Input: 5 3
1 2 3 4 5
1 3
1 5
5 5
Output:
10 35 15
Название |
---|