Skip to content Skip to sidebar Skip to footer
Showing posts with the label Algorithm

How Does Self.next = None Get The Next Value Of L1?

I was working on one of the problems on Leetcode (problem 21). It asks me to merge two sorted linke… Read more How Does Self.next = None Get The Next Value Of L1?

Python: How To Implement Binary Filter On Rgb Image? (algorithm)

I'm trying to implement binary image filter (to get monochrome binary image) using python &… Read more Python: How To Implement Binary Filter On Rgb Image? (algorithm)

Should I Optimize Around Reads Or Cpu Time In Google App Engine

I'm trying to optimize my design, but it's really difficult to put things in perspective. S… Read more Should I Optimize Around Reads Or Cpu Time In Google App Engine

Ordering Concave Polygon Vertices In (counter)clockwise?

I have a set of disordered vertices that may form a concave polygon. Now I wish to order them in ei… Read more Ordering Concave Polygon Vertices In (counter)clockwise?

Fastest Method Of Getting K Smallest Numbers In Unsorted List Of Size N In Python?

What is the fastest method to get the k smallest numbers in an unsorted list of size N using python… Read more Fastest Method Of Getting K Smallest Numbers In Unsorted List Of Size N In Python?

Split A String Into Pieces Of Max Length X - Split Only At Spaces

I have a long string which I would like to break into pieces, of max X characters. BUT, only at a s… Read more Split A String Into Pieces Of Max Length X - Split Only At Spaces

Group Consecutive Integers Together

Have the following code: import sys ints = [1,2,3,4,5,6,8,9,10,11,14,34,14,35,16,18,39,10,29,30,1… Read more Group Consecutive Integers Together

Stacking Boxes Into Fewest Number Of Stacks Efficiently?

I got this question in an online coding challenge. Given a list of boxes with length and widths (l,… Read more Stacking Boxes Into Fewest Number Of Stacks Efficiently?

Python Efficiently Split Currency Sign And Number In One String

I have a string like '$200,000,000' or 'Yan300,000,000' I want to split the currenc… Read more Python Efficiently Split Currency Sign And Number In One String

Generating All The Combinations Of Two Lists And Output Them One By One In Python

I have two lists [1, 3, 4] [7, 8] I want to generate all the combinations of two list starting fro… Read more Generating All The Combinations Of Two Lists And Output Them One By One In Python

Finding Natural Numbers Having N Trailing Zeroes In Factorial

I need help with the following problem. Given an integer m, I need to find the number of positive… Read more Finding Natural Numbers Having N Trailing Zeroes In Factorial

Nameerror: Name 'current_portfolio' Is Not Defined

I am getting NameError: name 'current_portfolio' is not defined def initialize(context): co… Read more Nameerror: Name 'current_portfolio' Is Not Defined

Divide Image Into Rectangles Information In Python

I have a series of images that are nothing more than a series of colored rectangles in a black back… Read more Divide Image Into Rectangles Information In Python

Cut Peaks And Troughs

Here is an algorithm I would like to implement using numpy: For a given 1D array, calculate the max… Read more Cut Peaks And Troughs

Finding The Max Of Each Continguous Subarray Of A Given Size

I'm trying to solve the following problem in Python Given an array and an integer k, find the … Read more Finding The Max Of Each Continguous Subarray Of A Given Size

Fast Way To Select N Items (drawn From A Poisson Distribution) For Each Element In Array X

I am having some trouble with solving a problem I encountered. I have an array with prices: >>… Read more Fast Way To Select N Items (drawn From A Poisson Distribution) For Each Element In Array X

How To Sort An Array With N Elements In Which K Elements Are Out Of Place In O(n + K Log K)?

I was asked this in an interview today, and am starting to believe it is not solvable. Given a sort… Read more How To Sort An Array With N Elements In Which K Elements Are Out Of Place In O(n + K Log K)?

Where Does The Performance Boost Of Map Or List Comprehension Implementations Over Calling A Function Over A Loop Come From?

I understand that you could be more efficient with memory in the implementation of map than in how … Read more Where Does The Performance Boost Of Map Or List Comprehension Implementations Over Calling A Function Over A Loop Come From?

C# Split A List Into All Combinations Of N Groups - Code Migration From Python

There is a great implementation of the algorithm I am after here (by @lazy dog). However, I need t… Read more C# Split A List Into All Combinations Of N Groups - Code Migration From Python

When To Stop When Number Is Not A Happy Number

A happy number is defined by the following process. Starting with any positive integer, replace the… Read more When To Stop When Number Is Not A Happy Number