Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
3 answers
139 views

Another ATMs cash-out (denomination) algorithm in Java

Related to this question and this answer, I would like to have a second review from you on a modified version. The problem I tried to solve Some kind of "Minimum count of numbers required from ...
Tobias Grothe's user avatar
3 votes
2 answers
222 views

Counting duplicate elements in two sorted arrays

I've been working on an assignment that involves optimizing a duplicate finding algorithm for sorted arrays, and I'd like to get your thoughts on the implementation. Here's the code I've come up with: ...
Bryan C's user avatar
  • 31
0 votes
1 answer
62 views

The Matrix Winds In

The Problem: Given an N by M Matrix, Create an Anti-Clockwise Traversal Path that winds in all the way into the Matrix Example: The Matrix is 9 by 5 Output: ...
Amal Krishnan's user avatar
1 vote
1 answer
107 views

Selection algorithms (order statistic) in Java: linear time vs. sorting selector vs. Quickselect

This post is about computing order statistics: given an array \$A\$ (not necessarily sorted), find the \$k\$th smallest array component. The entire repository is here. ...
coderodde's user avatar
  • 31k
1 vote
1 answer
89 views

Java - Select the maximum integers from sliding windows over an array

So I have the following algorithm. Given an array A[0 ... n - 1] and the window length w, compute all the windows ...
coderodde's user avatar
  • 31k
2 votes
1 answer
177 views

Change values in array until no consecutive values

I have to find an algorithm to solve this question : You have an array with n integers in it. Make an algorithm that changes array so that there are no consecutive expressions in it and returns the ...
lux's user avatar
  • 23
5 votes
4 answers
572 views

Fastest function to find cumulative largest perfect squares of a single number?

I'm attempting to write an algorithm that will find the largest perfect squares of a given integer, subtracting their values from the total each time, as fast as possible. It's somewhat hard to ...
Will Berner's user avatar
0 votes
3 answers
2k views

Calculate square of (sum of even-indexed) - (sum of odd-indexed) subarrays from an array

Find all subarrays from a given array in the least possible time complexity. Requirement: calculate the square of (sum of even-indexed elements) - (the sum of odd-indexed elements) of al the subarrays....
Adil's user avatar
  • 101
1 vote
1 answer
270 views

Find Kth Element in the merged two sorted arrays?

We have been given two sorted arrays and a number K . We have to merge the two sorted arrays in the sorted manner and return the element at the Kth position. My approach is to use two variables ...
Aryaman 's user avatar
7 votes
1 answer
346 views

Create tweet threads from String in Java

I recently got this question in an exam, this is how I implemented, it is working fine. However, I would like to know if the code can be improved, as I think it for sure needs to be improved. The ...
isanma's user avatar
  • 73
3 votes
1 answer
4k views

Count the number of distinct subarrays

I want to determine the number of distinct subarrays that can form having at most a given number of odd elements. Two subarrays are distinct if they differ at even one position. The subarray is a ...
wagaga's user avatar
  • 31
1 vote
1 answer
96 views

Java array extension/reduction

I work with the Oracle JGeometry method which returns (or takes as method argument) 2D segments as double array (x1,y1,x2,y2 ... xn,yn). I need to extend this array to contain 3D segments as double ...
Sir Montes's user avatar
0 votes
2 answers
934 views

Sum of 2 numbers in an array [closed]

I have this problem to solve: Given an integer \$z\$ and an array \$a\$ of distinct integers sorted in ascending order, find two numbers, \$x\$ and \$y\$, belonging to the array such that \$x + y = z\...
lettomobile's user avatar
2 votes
2 answers
175 views

Code for getting the coordinates of points on the chart

I am a beginner android developer. I am working on one of my applications. For this application, I wrote an algorithm that is needed to obtain data that is used to build a diagram. I have a list of ...
Destroyer's user avatar
  • 459
4 votes
5 answers
1k views

Counting number of `1` digits in the value of \$11^n\$

I am trying to improve the efficiency of my code, The Question is: Given a value n, where n is in the range ...
Prash's user avatar
  • 41

15 30 50 per page
1
2 3 4 5 6