Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
4 votes
2 answers
232 views

Ruby Array#own_shuffle method

I have tried to implement the Array-shuffle method myself. Haven't had a look on some similar algorithm-examples by purpose and tried to figure out something myself. The actual Array-extension: ...
michael.zech's user avatar
  • 4,972
4 votes
1 answer
102 views

Swift Arrays: Write a rotate-right function

Task: Write a function which rotates all elements of a given array to the right. Example: [1, 2, 3] => [3, 1, 2] My solution: ...
michael.zech's user avatar
  • 4,972
3 votes
1 answer
102 views

Merge discrete integer intervals

What it does The code starts with a set of integer intervals, and can add new intervals (possibly by updating existing intervals). Essentially, it is a bit array whose index starts at ...
FromTheStackAndBack's user avatar
-2 votes
1 answer
63 views

I wrote a O(log N) code for largest element in an array today but is this an already existing way to find max element in an array? [closed]

Largest element in an array's most optimal approach. The code I have written has passed all test cases in https://www.naukri.com/code360/problems/largest-element-in-the-array-largest-element-in-the-...
im3shn's user avatar
  • 1
1 vote
3 answers
138 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
2 votes
2 answers
84 views

Calculating the sum of all k-sized sub-arrays in an array using sliding window algorithm

I need to calculate the sum of all k-sized sub-arrays in an array using sliding window algorithm. Is that a valid sliding window algorithm? If not, why? ...
Alekam's user avatar
  • 21
3 votes
2 answers
221 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
3 votes
1 answer
135 views

Recursive Factorial Calculation in JavaScript

...
TAHER El Mehdi's user avatar
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
4 votes
3 answers
766 views

Determine whether two arrays have the same elements with the same multiplicities

I have written a Python function called comp that checks whether two given arrays have the same elements, with the same multiplicities. The multiplicity of a member ...
TAHER El Mehdi's user avatar
1 vote
1 answer
62 views

Optimizing the Dig Pow function

I have written a Python function to solve the Dig Pow problem, where the goal is to find a number k such that the sum of each digit of n raised to a specific and ...
TAHER El Mehdi's user avatar
8 votes
4 answers
523 views

Array List C implementation

I want to show you my implementation of the array list in C. Is there something I can improve or fix? Header ...
whiteman808's user avatar
1 vote
1 answer
274 views

C# Get All Diagonals Jagged Array

How can I improve this? The idea is to store every left to right diagonals in a list Not looking for a more efficient algorithm instead something readable, LINQ perhaps? input: 3, 1 2, 5, 7 1, 5, 8, 3,...
Laycoonz's user avatar
  • 133
3 votes
2 answers
406 views

Calculate sum of largest sequence of decreasing odd ints

I wrote a method that finds the maximum sum of consecutive decreasing sequence of odd integers. For example: if sequence is 13 9 7 12 13 15 13, then sum is 29 (13 + 9 + 7). I don't think it's as good ...
infelixPuer'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

15 30 50 per page
1
2 3 4 5
17