Let’s say we have two arrays: array1 = [2,3,6,7,9] array2 = [1,4,8,10] I understood how to find the kth element of two sorted arrays in log(min(m,n)) where m is the length of array1 and n is the length of array2 as follows: But I couldn’t figure out how to extend this to multiple sorted arrays case. For example, given 3
Tag: algorithm
Recursion ( kind of sub-set sum, but not exactly ) – True if can buy pens at exact price, else False
I have this question: you have a list of [7,9,11] pens. you have a function: you need to check whether or not if you can buy the exact amount. for example, I have X=23 I can buy 1*9, 2*7 I just need to return True if it is able, false else. I saw the answer, they did it brute force
Given array of string contain X number of words return the same word for a given day [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago. Improve this question Background My Objective is I am basically trying to create an end point where a user calls the get_word() function
Best Way to Implement a Custom lower() method in Python
I have an assignment where I’m not allowed to use the .lower() function so I’m creating my own. At the moment I have two ideas on how to do this but would love some input on what the most efficient way would be. Method 1: Using if elif function This is the most basic way I could think of, simply
Finding the coordinates of max sum path in matrix
I have this method which returns the max sum of the path from top left to bottom right (can move only to the right or bottom). output : 1 + 3 + 4 + 5 = 13 But what I want to get is also the coordinates of the points of the path: [(0,0) (1,0) (1,1) (1,2)] Answer The variable
Values don’t change as they should because of recursion depth
I am making checkers. I encountered quite a big problem. The code below describes cells king can move on. 1 cell is 100×100. He starts from (550, 50). This picture describes current_battlefield: And this dict describes what moves AI will take The king is a purple checker and he has to eat right now. So, about the actual problem. If
Finding any changes between two lists of the same length
Given 2 lists of the same length. Is it possible to return a dict containing any changes between the 2 lists. Each key being the value that was changed and the key’s value being the value it was changed to. The following returns difference between the 2 lists: I am looking to go one step further and save the results
How do I create a matrix (values possibly empty) from columns and rows?
I have a table that contains actual data as well as empty cells. I want to parse it programatically but have some trouble doing so. Example: A E B C G H I also have an array of rows and columns, like: rows columns { {A; E} {B} {C; G} {H}} { {A; B; C} {E; G; H}} With this
Algorithm verification: Get all the combinaison of possible word
I wanted to know if the algorithm that i wrotte just below in python is correct. My goal is to find an algorithm that print/find all the possible combinaison of words that can be done using the character from character ‘!’ (decimal value = 33) to character ‘~’ (decimal value = 126) in the asccii table: Here the code using
Sort the digits of a 1GB file containing a single number efficiently
I’m trying to print in ascending order a 1GB file containing a randomly generated big number. This is the code that I’m using to generate the random number for my test (found it here). The following python code works OK and takes a bit less than 4 minutes. But I was told this can be accomplished in about 15 seconds