Skip to content
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms and Conditions

Programming Tutorial

Start Learning to Code

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms and Conditions

Breaking News

Nextjs: running code after complete fetch

why does 400 status code result always entercatch block execution with axios?

Saving the state of the button onClick

TypeScript: Specify that value must be in Array using spread operator

Show separate number with comma in django tempalte

Why does my website keep showing old index.html, style.css, app.js…?

Using Python Flask to change the colour of an icon when it detects a words like scam, pending and verified

x clear icon appears only when the input has value – react

Login button redirects to two pages. For first time loginers, it redirects to agreement page, and for rest, it redirects straight to home?

WebComponent setter not triggered if defer is used

Tag: algorithm

Arrays

How to find the maximum consecutive, negative sum in an array?

admin May 18, 2021

What is the most efficient way to calculate the most negative sum for any set of consecutive indexes in an array? You can take any consecutive group of positive and negative integers in an array to …

algorithmarrayspythontime-complexity
Arrays

Get the last character of string inside array

admin April 24, 2021

The question required me to get the first char from the first word in array with the last char from the second word in an array I can just get the first char but my problem is with the second one like:…

algorithmarrayscodeigniterjavascriptstring
Arrays

How can I optimize my code from O(n^2) to nlog(n)

admin March 21, 2021

Given an array of numbers, arrange them in a way that yields the largest value. For example, if the given numbers are {54, 546, 548, 60}, the arrangement 6054854654 gives the largest value. And if the …

algorithmarrayscstring
Arrays

How to sort array of objects based on object property (which is Array) Javascript

admin March 16, 2021

I’ve got this groupsArray which I want to sort based on the days which are closest to 1 and the times start and the end should be the earliest ones… I’ve tried a lot of stuff but I was unable to …

algorithmarraysjavascriptobjectsorting
Arrays

modified version of selection sort in C

admin March 16, 2021

I’m trying to modify selection sort in such a way that it puts the biggest element at the end of the array and then repeats selection sort for n – 1 items until n is 0. My code compiles but the output …

algorithmarrayscselection-sortsorting
Arrays

PHP: Find one or more enclosed area in a two-dimensional array

admin March 11, 2021

There is (10×10) two-dimensional array (matrix) of zeros and ones. Need algorithm (the implementation) that determines whether in this array closed path of ones, that surround the zeros. The output is …

algorithmarraysphp
Arrays

Maximize the sum of absolute difference between max and min elements of all non overlapping sub-arrays that can be formed from an array?

admin March 3, 2021

for example : A = [2, 3, 0, 1, 5] Now A can be divided into multiple sub-arrays One way to do so is : A ~ [2], [3, 0], [1, 5] Now the sum of absolute difference between max and min elements of all non …

algorithmarraysgreedy
Arrays

Find first non zero numbers in an array (zeroes can be anywhere)

admin February 26, 2021

Suppose we have an array: x = [10,0,30,40]. I would like to extract the first non zero element and store it in a different variable, say y. In this example, y = 10. We can also have many zeros, x = […

algorithmarrayspython
Arrays

How would you solve this problem using a hash map instead of a set?

admin February 24, 2021

def pair_sum(array,r_sum): if len(array)<2: return found = set() output= set() for num in array: k = r_sum - num if k not in found: found.add(num) else: output....

algorithmarrayshashmappythonset
Arrays

Prefixes using array in java [closed]

admin February 18, 2021

I’m coding a method that takes as input an array of integers and returns another array of strings, each of which denotes a non-empty prefix of the input array. For example, if the input array is: <…

algorithmarraysjavaloopsprefix

Posts navigation

1 2 … 12 Next
Privacy Policy