
In this problem we work with Latin squares and matrix traces.
A Latin square is an NbyN square matrix in which each cell contains one of N different values, such that no value is repeated within a ...

I have got two strings of equal length. Each string contains digits '1' to '9'.
I want to calculate the number of indexes where the character at that index is same between the two strings.
Example ...

Apologies if this kind of question is not allowed here.
I came across this question: "Given a list of intervals representing the start and end time of ‘N’ meetings, find the minimum number of rooms ...

I was reading an post on stackoverflow.com
Looking for algorithm finding euler path
When read the first answer of question(having 21 upvotes) he is saying
If all vertices have even degree: choose ...

The problem which I am struggling with is given below:
Suppose you have a binary string S and you are only allowed to do one operation i.e. RightRotate by Kbits where K = [0, Length of the string]. ...

I Wonder if there is a function recursive to search all the way in order to optimize the cost of this problem I will describe the problem as below:
It is a question of affecting all the families ...

currently I have to write a webtool for modeling some shapes with Leaflet. Similar to Microsoft Visio. So there are shapes like rectangles filled with markers/circles in rows. The user should be able ...

I have encountered this claim in one of "Data Structures" book about Algorithm Analysis: creation of a new string as a result of a concatenation, requires time that is proportional to the length of ...

Why does the Floyd's cycle detection algorithm assume that the tortoise will do at most a single lap around the cycle before it meets with the hare? Why can't it do multiple laps?
Both the intuitive ...

A BST T1 is rightconvertible into another BST T2 if T2 can be obtained from T1 by performing only right rotations on T1. I need to prove that this operation can be done in $O(n^2)$ right rotations.
...

What should be the time complexity of the following code?
I tried to think and come up with O(n2) but the output says it to be of O(n).Can someone please explain through code?
for(int i = 0; i < n;...

I am trying to find the solution of lights out game using backtracking method. I am not able to understand the algorithm for this process. My approach is to enumerate all integers from 0 to pow(2, n * ...

First of all, thank you for reading it. I am new to Python and learning something new every day.
I wrote a function where inputs are 4 variables and output are 4 variables.
My problem is variables ...

How can I replace consecutive characters with a single character in java?
String fileContent = "def mnop.UVW";
String oldDelimiters = " .";
String newDelimiter = "!";
for (int i = 0; i < ...

The premise of the question is given some dominoes, what is the longest row of dominoes that you can place down such that adjacent sides of neighboring dominoes have the same label? An example list of ...

I am working on a problem where I have to output the smallest number bigger than N consisting of the same digits as N. If there is no such number, I must print "0" as the output. This is the code I ...

I recently enrolled to CS50 AI python course and one the projects to do is to implement a minimax algorithm for a tictactoe game. I looked for help and searched stackoverflow but I didn't find an ...

I'm currently trying to solve a problem where I have a list of deliveries(pick ups and drop offs) that need to be completed and I need to find the path through all of them with the lowest travel time. ...

I'm trying to write a program that sorts integer elements of an array, using a Binary Search Tree(BST) as support data structure.
The idea is that once the array is given, then it is possible to use ...

I would like to receive help in understanding why my solution to Problem 3 of the Google CodeJam 2020 Qualifier does not work.
Link to problem: https://codingcompetitions.withgoogle.com/codejam/...

I'm having a little bit of trouble trying to figure out an efficient algorithm to solve this problem. You are given a long string
s="a bcd e f ghi j k lmn opq ghfdj ashks jahksjh jahkdaj jhakjd ...

I have the following class ListNode
class ListNode {
constructor(val) {
this.val = val
this.next = null
}
}
I am trying to delete repeat values by storing the values in a ...

I'm wondering how to go about solving this problem.
I'm given a graph G = (V,E). It's an undirected weighted graph that's connected. The graph consists of a spanning tree and one edge. How would I ...

May you kindly assist here, i'm new in programming .
An algorithm that asks a user to enter a positive number repeatedly until the user enters a zero value. Then determine and output the largest of ...

I have two different linked lists, and I try to pop one node from the first linked list and to to the second linked list. My goal when calling the pop function (pop(Node * head)) is to update the new ...

I have multiple date ranges each with a start and end date/time, containing a single value from which I want to create new ranges, where the overlapping range values are appended to a slice.
Date/...

Given a BST and a positive integer k, find the k_th smallest element in the BST.
For example, in the following BST, if k = 3, then output should be 10, and if k = 5, then output should be 14.enter ...

I am trying to solve (1787. Turn for MEGA) . I have written the following code. It shows wrong answer when I am submitting it. I have given a lot of input. In my pc this program is showing correct ...

I have a 2d array, matrix of a sort (m x n). I need to generate '1' in k cells, but the probability of it should be equal for each cell.
for example, if k=3, we pick randomly where to place the 3 '1'...

We have an array A[1...n]. In inversion is when i < j but A[i] > A[j].
I want a way to describe the maximum number of inversion that an array A of length n can have (consider that the starting ...

Long story short, I came up with this algorithm, but I doubt that I invented something. So what's the name of this?
I know it has a lot of restrictions in multiple areas. For instance this ...

You have to transport a maximum of 15 different loads from one port to another. Carrying capacity of a cargo ship, which will transport those loads, is 50 tons. Loads are enumerated and the ...

I've been recently asked this question in an interview. Question is as follows:
Given heights of player of two football teams in array A and array B respectively. Now, you have to tell if you can ...

Like the title says, i need to find the difference of integers in a list by 2 and must return a list with tuples.
initial_list = [1, 2, 3, 4]
expected_output = [(1, 3), (2, 4)]
I wrote this code:
...

This is in reference to this question.
We have to minimize the Value of Vote Value Disparity.
By analyzing the term i have found that we have to minimize the difference between minimum and maximum ...

its giving an error of heap buffer overflow.
the question is to find the median of two sorted arrays.
double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size){
int n = ...

I need help to figure out a simple heuristics (which is admissible / never overestimates), using A* search, for the AI problem:
Please note: I have implemented the advanced problem where I can pick ...

Im working on a simple tictactoe AI using the minimax algorithm in Kotlin. It somewhats seems to work but it fails in this scenario:
I move first and am 'X'. AI is 'O'
X  

 ...

I have to make a documentation about basic BeOS information.
I should know what's the scheduling algorithm followed(SJF, FCFS...) and if it follows a layered,simple,microkernels,or modules approach. ...

Note: I'm very much from a programming background, not a mathematics background. This will become obvious very quickly.
Assume I have a bounded ndimensional space  for example here I'll use n=2. In ...

I need to rotate the tree after every insert, and it goes well while I add only lesser/greater value than his parent. I mean, if I insert 643 the resulting tree after the 2 rotations will be (read ...

I'm trying to convert some excel files that have bus schedules by bus route/stops.
Only data available on the excel files are bus route number, ordered list of bus stop names for the specific bus ...

I want to generate random numbers within a range (1  100000), but instead of purely random I want the results to be based on a kind of distribution. What I mean that in general I want the numbers "...

I want a function that given an N: Int and a K: Int returns an Array length N, elements from 1...N and total sum K.
So for example:
For n == 3 and k == 7
Solutions:
[3, 1, 3], [3,3,1], [3,2,2] ...
...

Blockquote
I've been making the game Bulls and Cows on C#.
In the end, I come to a number that contains all the bulls and cows.
I want to sort them until they are 4 bulls.
Example:
My number: 1234
...

I'm trying to solve the extension to a problem I described in my question: Efficient divideandconquer algorithm
For this extension, there is known to be representatives for 3 parties at the event, ...

I have problem with changemaking problem algorithm.
My function coin_change_solutions works well with small numbers.
For example if we pass [1,10,25] as coins and 32 as S (change that we want to ...

I have been given x and k, where x is the number of factors of a number A, and k is the number of prime factors of A. Given x and k, I have to find out whether such an A exists.
For example:
INPUT : ...

The title is a mouthfull, but put simply, I have a large, undirected, incomplete graph, and I need to visit some subset of vertices in the (approximately) shortest time possible. Note that this isn't ...

I'm solving this beginner problem on Codeforces, Young Physicist.
https://codeforces.com/problemset/problem/69/A
The answer is to find if 3 forces are in equilibrium.
I've submitted two versions of ...