## itsvks

BAN USER- 0of 0 votes

AnswersYou are given a String S of length N. Now, a good subsequence is one that can be represented in the form (a raised to the power i) (b raised to the power j) (c raised to the power k) where i≥1, j≥1 and k≥1. For example ,if i=2, j=1, k=3, it represents the string aabccc. In short, a good subsequence is a subsequence that first consist of

- itsvks in United States

i ′a′ characters, followed by j ′b′ characters, followed by k′c′ characters, where i≥1, j≥1 and k≥1

Now, you need to find the number of good subsequences of String S. As the number of such subsequences could be rather large, print the answer Modulo

(10 raised to the power 9) + 7.

Note: Two subsequences are considered different if the set of array indexes picked for the 2 subsequences are different.

Input : abcabc

Output : 7

Explanation

Valid sub sequences are(1-based indexing):

{1,2,3}

{1,2,6}

{1,5,6}

{4,5,6}

{1,2,5,6}

{1,4,5,6}

{1,2,3,6}| Report Duplicate | Flag | PURGE

Amazon SDE-2 - 0of 0 votes

AnswersCross the River

- itsvks in India

Saatwik, an elite programmer love the woods. Once he was in one of his trips to the mighty Himalayas , he encountered a strange problem. As we all know that, Himalayas has abundant river streams and forests. While travelling in one of the forest, he was trapped by the river stream flowing. As the stream flow was fast, he couldn't cross by swimming across water, he must find some other way to cross it.

River is present throughout the X axis and its boundary is marked by y coordinates (i.e. from y=A to y=B) .

--------------------------------------------------------------------------------- (y=A)

..................................................................................................

..................................................................................................

..................................................................................................

---------------------------------------------------------------------------------- (y=B)

Now, You are provided with some rocks along with their centres and radius respectively. Currently Saatwik is present on the shore having y=B . We can't jump between the rocks but we can move from one rock to other if both overlap at some points. You need to tell whether Saatwik will be able to cross the river by using any number of rocks or not . If he can, then output the minimum number of rocks taken to achieve it otherwise output −1

Input :

First line of input will contain T denoting number of test cases. For each of the test cases, First line will contain N denoting number of rocks. From second line onward, there will be N lines containing 3 integers X,Y,R where (X,Y) denotes the coordinates of the centre of that rocks and R stands for its radius. Last line will contain two integers A and B denoting the upper and lower boundary of the river respectively.

Output:

Output the required answer in a separate line for each of the test case.

Constraints :

1≤T≤10

1≤N≤5000

−109≤X,Y,A,B≤109

1≤R≤109

B<A

Sample Input

1

3

1 1 2

1 2 1

3 4 1

3 0

Sample Output

1

Explanation

At first we can step onto the first rock from the river shore. Then we can cross river directly or can move to second rock and then cross it. Note that we can't use third rock as it is beyond the reach from the other rocks.

Time Limit: 2.0 sec(s) for each input file

Memory Limit: 256 MB

Source Limit: 1024 KB| Report Duplicate | Flag | PURGE

Cleartrip.com Software Developer Algorithm - 0of 0 votes

AnswerGiven an array A of size N, where the ith integer of the array is A[i] and has a value ranging between 1 and 1000 inclusive, you need to help Monk with the following task :

- itsvks in India

Given 3 additional numbers K, X and Y, you need to report the number of un-ordered pairs of elements (i,j) from this array, such that (1≤i<j≤N), (A[i]+A[j])%K=X, and (A[i]×A[j])%K=Y.

Input Format :

The first line contains 4 space separated integers N, K and X and Y. The next line contains N space separated integers where the ith integer denotes A[i].

Output Format :

Print the required number of ordered pairs of array elements on a single line. As the answer could be rather large, beware of integer overflows.

Constraints :

2 ≤ N ≤ 10 raised to power 5

1 ≤ K ≤ 10 raised to power 6

0 ≤ X, Y < K

1≤A[i]≤1000

Sample Input

5 2 1 0

1 2 3 2 1

Sample Output

6| Report Duplicate | Flag | PURGE

Cleartrip.com Software Developer Algorithm - 1of 5 votes

AnswersConsider a hotel where the guest is checked in and check out. Find a day when the maximum number of guests stay in a hotel.

- itsvks in Netherlands

example:

Input :

[

{check-in : 1, check-out 4},

{check-in : 2, check-out 5},

{check-in : 10, check-out 12},

{check-in : 5, check-out 9},

{check-in : 5, check-out 12}

]

Output : 5| Report Duplicate | Flag | PURGE

Booking.com Software Engineer / Developer Algorithm - 2of 2 votes

AnswersGiven number N, Find the least number of perfect square number sum needed to get N.

- itsvks in Netherlands

Example :

n=5 (4+1) i.e. 2

n=7 (4+1+1+1) i.e. 4

n=12 (4+4+4) i.e 3

n=20 (16+4) i.e. 2| Report Duplicate | Flag | PURGE

Booking.com Software Engineer / Developer Algorithm

RepSpent high school summers donating toy monkeys in Minneapolis, MN. At the moment I'm building glue in Edison, NJ ...

Rep**marktrejjo**, Data Engineer at Accolite softwareI’m Mark.I believe life is too short to be serious all the time, so if you cannot laugh ...

Rep**angelafiecke**, Blockchain Developer at ASUI am a Data processor at DGS VolMAX. I will also be a controller for the data I use for ...

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

- itsvks February 08, 2017