The problem: In this task, you need to write a regular segment tree for the sum. Input The first line contains two integers n and m (1≤n,m≤100000), the s
I was attempting this question on leetcode using python3. My solution for this problem is as follows: class Solution: def __init__(self): self.memo
I know how to apply Kleene star on language but I'm not sure how would I apply it to DFA or NFA. I'm pretty sure it would need to be epsilon NFA with initial st
I want to make a search program but i stuck in specific alogrithm. First, I will get any word from users Then check wheter user's words are included in any keyw
How to rotate right and left over an arbitrary number of bits. So say I am looking at 5 bits. How do I rotate around 5 bits, though I am in JavaScript. Or 8 bit
My assignment: Consider two arrays a and b where each consists of n integers. In one operation: Select two indices i and j (0 <= i,j < n) Swap integers a
Given an array having n elements, find all the possible pairs of elements whose product is between x and y provided by the user, i.e. all i and j less than n, s
I am trying to solve an optimization problem for a graph, where basically there is a cost for transporting "package" over a single edge, and I have multiple sou
I'm working on the Island Perimeter Problem from LeetCode. I tried to use the DFS algorithm, based on LeetCode#200, to solve this problem. For example 1, the ou
I have a dataset comprised of n unsorted tuples representing numbers (let's say specific color codes) and their frequency (number of times of appearance). I wan
My Code ↓ Some macros defined by #include <stdio.h> #include <malloc.h> #define ElementType int #define ERROR 0 // 队列ஷ
I am taking a course in python and one of the problem sets is as follows: Read in the contents of the file SP500.txt which has monthly data for 2016 and 2017 a
Using PyGAD Package, how to generate the item of populations with element not duplicate between 1 and 12? It is always has duplicate value in random population.
Section 4 of this paper states that it is easy to see that A* is equivalent to dijkstra used on a modified graph where edge weights add the potential from the o
Consider two vectors: vector<int> A = {1, 4, 3}; vector<int> B = {5, 7, 1}; It's given both vectors are of equal length. If I need to use element b
I'm trying to solve the cannibals and missionaries problem in python (with some additional criteria, but the main idea is the classic one). So, in the class Gra
I got a partition problem for which I need advice. I'm given a 1D array whose length is even. I need to write a boolean method to determine whether the array ca
given: public void trash(int n){ int i =n; while (i > 0){ for (int j = 0; j < n; j++) { System.out.println("*"); i
I'm trying to swap the 2nd and 4th elements in a list, but I can't figure out how to do this. I tried to use vector notation, but it didn't work. list<int>
My understanding is that BFS and DFS are graph traversing algorithm while other algorithms like A* and dijkstra are for finding shortest path between two nodes