Skip to main content

All Questions

4 votes
4 answers
1k views

Creating an O(n) algorithm for an array of integers

To avoid plagiarism in my university, I am going to modify the problem. Henry likes to jump from building to building. The heights of each building are given as a list of H numbers. We also number ...
Lesserrafim's user avatar
1 vote
2 answers
320 views

Python script that makes generalized Ulam spirals

This is a Python script I wrote to generate generalized Ulam spirals. I call the spirals generated by my code Ulamish spirals, they are one dimensional polylines that cross all two dimensional lattice ...
Ξένη Γήινος's user avatar
6 votes
3 answers
821 views

Python script to split overlapping ranges, version 4

This is the fourth iteration of a Python script I wrote that splits overlapping ranges, and this is the fastest version I have wrote so far, and also a version that works for all inputs. I have done ...
Ξένη Γήινος's user avatar
2 votes
3 answers
404 views

Most effective search algorithm for guessing list of strings via function returning bool if substring is in list using Python

I trying to figure out the most effective way to accomplish this task: A function, check(), contains a list of strings. Calling the function with a string as ...
n0k's user avatar
  • 21
4 votes
3 answers
283 views

Increase efficiency of stick cutting algorithm

I have this typical code interview type problem. Suppose you have a stick of length n. You make X cuts in the stick at places x1, x2, x3 and so on. For every cut in X cuts you need to print the length ...
Some nerd who does not have a 's user avatar
7 votes
3 answers
1k views

Algorithm which finds the count of values are smaller to the right than the current one (in the list)

I have to solve the task which finds the count of values, are smaller than the current one, located to the right. Here is the example: ...
rockzxm's user avatar
  • 171
2 votes
1 answer
301 views

Python functions that calculate first n terms of a given order of Fibonacci sequences

I have written two functions that calculate the first n terms of a given order o of Fibonacci sequence, and return the result as ...
Ξένη Γήινος's user avatar
4 votes
4 answers
1k views

Count numbers that are the sum of three perfect cubes

From numbers from 1 to 100, count the numbers where the following equation is satisfied with 1 <= a <= 100, 1 <= b <= 100, and 1 <= c <= 100: $$a³ + b³ + c³$$ I have this: ...
Alan Bagel's user avatar
3 votes
1 answer
537 views

Optimizing Dijkstra on grid Python (Microsoft Interview)

Given a square grid of size N, each cell of which contains integer cost which represents a cost to traverse through that cell, we need to find a path from top left cell to bottom right cell by which ...
Shubham Prashar's user avatar
5 votes
1 answer
217 views

Algorithm Optimization -- Automatic Dimensionality of PCA

I have implemented (rather, edited the implementation of) a technique to automatically detect the optimal number of dimensions for PCA, based off of this paper. This was inspired by ...
artemis's user avatar
  • 193
3 votes
0 answers
2k views

Optimizing recursive backtrack search algorithm in Skyscraper puzzle

I'm trying to solve a skyscraper puzzle for 6x6 boards using constraint programming and then backtracking. My solution works but is too slow, for certain cases, it takes up to 2 seconds and I was ...
AdamA's user avatar
  • 31
4 votes
1 answer
94 views

Job Scheduling Algorithm

Changed Program based on suggestions. New Code: Job Scheduling Algorithm 2 I have created an algorithm for job scheduling. The algorithm goes through sub-lists in order with two nested for loops. ...
Akash V Patel's user avatar
5 votes
3 answers
188 views

Analysing a Huge Codebase with Python

I've written a Python program to analyse a huge C++ code base in excess of millions of lines of code. The job of the program is simply to search for all C and C++ style comments and extract all the ...
jess's user avatar
  • 1,378
3 votes
2 answers
135 views

Is the following divide and conquer recursive algorithm for the exponentiation more efficient than the iterative one for large numbers?

I have the two following algorithms. My analysis says that both of them are \$\mathcal O(m^24^n)\$ i.e they are equivalent for big numbers (more than 32 bits). Is this right? Note that ...
asmmo's user avatar
  • 237
4 votes
1 answer
197 views

Multiple Pandas Ranking Operations within a Loop - Better Optimization and Performance

I have implemented the following code which works as intended. However, I would like to improve my code in terms of performance and efficiency Code in Question ...
aBiologist's user avatar

15 30 50 per page
1
2 3 4 5