nooooob
BAN USER
Comments (6)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Yes, it could be done in two ways.
1) Create an array of valid indices, i.e if you ever encounter X at index (k) it should point you to the valid character (B, C , D etc) i < k. And this could be factored in the KMP algorithm while matching the pattern with the string.
2) Remove Xs, and while doing it create an array that will give you indices of B, C, and D in the original input. In this case, run KMP and for valid outputs, you can get the indices information from the array while printing the results.
Let me know if you need an example.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Use Min Heap, min heap allows you to check with O(1), is the new entry in top 10 rates at the given time t.
- nooooob July 07, 2019For solving this problem, we could use min heap and hashmap. HashMap for locating existing video entry in heap in O(1) time. Asymptotically, O(10), linear search in heap of size 10 (implemented using array) is O(1). But for a considerable size of heap, we could use hashmap.