Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
2 answers
299 views

Find the highest product of three numbers in a list (Python)

I wrote the below as a solution to: Problem Find the highest product of three numbers in a list Constraints Is the input a list of integers? Yes Can we get negative inputs? Yes Can there be ...
msm1089's user avatar
  • 197
1 vote
1 answer
55 views

What is the optimal way to retrieve a list of sorted dates in a list of sorted periods in python?

Suppose I have a list with N sorted dates and M non-overlapping sorted periods with start date, end date (inclusive), and a tax rate for example. I have to make an efficient algorithm retrieve all tax ...
staticdev's user avatar
  • 113
3 votes
0 answers
303 views

Calculating the total sum of inversion count for all subarrays

My approach was to visit all inversion count pair and count how many subarrays these pair contribute. Visiting every pair requires \$\mathcal{O}(n^2)\$ time, but I want an optimized version of this, ...
Madfish's user avatar
  • 31
7 votes
1 answer
339 views

Extending the extended Stable Marriage Problem using a Python class

As soon as I saw this open source paper, I thought that the best way to replicate their code would be using a python class. After having replicated and extended the ...
B Furtado's user avatar
  • 133
4 votes
2 answers
457 views

Compare Strings

You have been given two strings, A and B (of length N each) and Q queries. The strings contain only 0s and/or 1s. For every query, you are given an index i. You have to update the value at ...
Ankur Anand's user avatar
4 votes
1 answer
184 views

Shakesort in Python 3

I've done the shakesort algorithm win \$O(n^2)\$, but it doesn't seem that \$O(n^2)\$ is correct because it takes 6-9 steps in the while loop for a list of 4 ...
jkansjkdkas's user avatar
9 votes
2 answers
2k views

Solving 'decent numbers' that follow specific division rules

HackerRank Problem Statement I have to find the largest 'decent number' having N digits. A decent number has the following properties: 3, 5, or both as its digits. ...
benSooraj's user avatar
  • 305