algorithm's questions - English 1answer

3.329 algorithm questions.

Single source shortest path In SSSP, we choose a node \$s\$ and we compute all the shortest path starting from \$s\$ towards all other nodes, thus computing a shortest path tree. Two most classical ...

Continuing where I left off previously to solve the problem described here, I've now solved the same using dynamic programming (following Tikhon Jelvis blog on DP). To refresh, the challenge is to ...

I'm given N integers. I need to find the maximum number of unique integers among all the possible contiguous subarrays of size M. ...

As part of learning Haskell, I'm solving few problems, usually solved imperatively. I've come up with a naive solution for the problem described here, which is to find a sequence in which to burst a ...

I am writing a program that compresses and decompresses data using the Huffman Coding algorithm. About compression: this program will export 2 files: header file (contains characters' frequency for ...

My idea is to make some testing system for functions, as per the model of CodeForces or TopCoder, but in VBA. There, the users write functions for a problem and the problems are tested vs. predefined ...

...

I have this method that takes a list of my individuals (class has public field fitnessValue). I sum all fitnessValue and then ...

Brief introduction for CSR: The compressed sparse row (CSR) or compressed row storage (CRS) format represents a matrix M by three (one-dimensional) arrays, that respectively contain nonzero ...

I am building an encryption program for a messenger app I am developing. I was wondering if the code looks clean and succinct, and at the same times is safe and secure: ...

The code is meant to find the longest substring that is in alphabetical order. I would like to know if I can do it more efficiently than I have done here. I am in my first week of my first ...

I'm trying to write a better code in python. I don't know where to start checking. I want to make sure that I do write a best practice code. This is the second problem in Hackerrank trie data ...

I wrote code in Python that takes a string s as input and determines the longest substring of s that’s in alphabetical order. In ...

I decided to solve a problem posted on Stack Overflow as a bit of fun. (I wouldn't post it there as they should attempt it themselves) The basic idea is to find the exam schedule which uses the ...

I'm building a bounding volume hierarchy in Golang. I can tell my code works because I did some test on it and it gives the same results as the brute force implementation (brute force is to test all ...

I decided to implement some data structures- this time an AVL tree. I think the logic is correct. Is there a way to make it clearer and do you have any ideas about more tests to add? ...

I designed a tic tac toe using 4 classes. The game class being the main class, the board class being the board, the player class being the decision making, and the AI class keeping the previous game ...

I have a binary tree below and it seems to make sense to overload the insert() method. If insert() is called without a ...

...

Here is my code to use range minimal query to resolve the LCA problem. I applied comments from here. Any advice on code bugs, performance improvement in terms of algorithm time complexity, code style ...

I tried this spoj problem and solved it using Dynamic Programming, but I was getting Time Limit Exceeded. The challenge is to count the number of occurrences of the subsequence "KEK" in each input ...

I am working on a batch file for doing date/time maths. One challenge is to determine the (proleptic) Gregorian year from the given number of days that have elapsed since day zero (that is, 1st of ...

My version of Knapsack works only when the weights or values of items are whole numbers. Restrictions You are given an array of objects each of which contains a weight and value. You are also given ...

I have implemented what is know as a countSketch in python (page 17: https://arxiv.org/pdf/1411.4357.pdf) but my implementation is currently lacking in performance. The algorithm is to compute the ...

This is my solution to find the combination of 2 overlapped rectangles implemented in JavaScript. rectangle is presented by 2 points(x,y). Can this code be improved? ...

I'm designing a new esoteric language, and the interpreter is in Python3. It is going to use Prefix Notation, so as part of the interpreter, I need a function that evaluates a string as prefix ...

Playing with https://ocaml.org/learn/tutorials/99problems.html#Miscellaneous-Problems I wrote a backtracking solver for the n queens problem, then the knight's tour, and realised I could generalise ...

I've written binary search with only my own efforts 💪💪 without glancing at anywhere. I stuck on finding base case. At final, I think that if last checking is less than first index or first checking ...

I am trying to implement a recursive count of inversions in a list of integers by using merge sort and counting the number of split inversions on each recursion. My code works but runs painfully ...

Background: Motivation behind writing the following code is originated in the area of computer vision. More specifically – image rectification. In order to obtain rectified images, one has to find a ...

This code returns an array that consists of two copies of the input array. Can you review this algorithm? ...

I am working on a compiler that does a pretty heavy work on strings in order to get them correctly displayed. So far I have an algorithm that transforms a given string like (In plaintext): ...

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 ...

My code is determining the difference between two iterables in terms of items that have been addded, removed and kept. The items are assumed to be sortable and there are no duplicates. ...

The code below is for Hackerrank competition. Seems that it works correctly but performs very slowly and because of it can't pass some tests. The task is to find the maximum GCD of all possible pairs ...

...

The Karatsuba algorithm, first published in 1962, aims to speed up the multiplication of big numbers by reducing the number of 'single-digit-multiplications' involved. Because of its complexity (...

I have a PriorityBlockingQueue in which I am adding SocketHolder. And let's say current datacenter where this code is running is ...

Objective: Create a heap sort that returns a unsorted list to sorted from greatest to least. Does this implementation look correct? Do you have any tips for optimizing this? ...

To find the days off for our custom accounting software there is this method used to find when is Easter in any given year. ...

I need to implement a method that adds a "7-3-1" check digit to my id. The "7-3-1" method works as following: Weights 7, 3, 1 are assigned to the original number from right to left. So if the ...

The question asks to rotate an image/matrix by 90 degrees. Ideally it asks to do it in place but before that I decided to do it using extra space because this is my first time working with matrices. ...

You have two sequences A and B consisting of integers, both of length N, and you would like them to be (strictly) increasing, i.e. for each K (0 ≤ K < N − 1), A[K] < A[K + 1] and B[K] < B[K + ...

I saw the below question on geeksforgeeks.org Given a set of numbers, find the Length of the Longest Geometrix Progression (LLGP) in it. The common ratio of GP must be an integer. Can someone ...

I have a processToTaskIdHolder Map which contains processId as the key and taskId as the ...

I have been trying to develop an algorithm called keep the tool needed soonest (for more information about the KTNS explanation (page 3)) but during the simulations, I have realized that it takes too ...

I solved the following problem: You will be given a mathematical string and your task will be to remove all braces as follows: ...

I've finished optimization of Wilson algorithm (maze generation) from "silly and slow" algorithm of choosing unvisited cells: ...

Recently I had an interview where it was asked: Given a list of people with their birth and end years find the year with the most number of people alive. I implemented in Java and was trying to find ...

Here's my code that takes a large string, and searches for the longest reoccurring substring. It compares the first letter with every other until it finds a match, then saves it. Then it compares the ...

Related tags

Hot questions

Language

Popular Tags