Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
101 views

I was just trying to implement cyclic sort after watching the theory part of a YouTube video (https://youtu.be/JfinxytTYFQ?list=PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ&t=889). I came up with the below ...
Nishanth K N's user avatar
2 votes
1 answer
4k views

I am trying to solve this code challenge: Given an array arr of n integers, in a single operation, one can reduce any element of the array by 1. Find the minimum number of operations required to ...
systummm's user avatar
2 votes
1 answer
61 views

I'm working on a project where I need to find the longest increasing subsequence (LIS) from a given array of integers. However, the array can be quite large, so I'm looking for an efficient algorithm ...
Navodya Vidumini's user avatar
0 votes
3 answers
198 views

I attempted to solve the problem at this HackerRank link (https://www.hackerrank.com/challenges/diagonal-difference/problem?isFullScreen=true) Given a square matrix, calculate the absolute difference ...
Mário Alfredo Jorge's user avatar
0 votes
2 answers
81 views

Let's say I have 2 arrays each of which holds a few different objects class Object1 {} class Object2 {} class Object3 {} class Object4 {} class Object5 {} class Object6 {} const arrayA = [ new ...
Charlie Martin's user avatar
-1 votes
2 answers
82 views

public int removeMin(Integer[] arr, int count) { Integer[] tempArr = new Integer[arr.length -1]; int index = 0; for (int i = 1; i<arr.length; i++) { tempArr[index] = arr[i] ...
ansh87's user avatar
  • 3
0 votes
1 answer
315 views

You are given two arrays each with n integers. Find the maximum sum of two elements. You have to choose one element from the first array, one element from the second array and their indexes have to be ...
Tomek Swiecki's user avatar
1 vote
1 answer
85 views

I have a List and Map as below, val exampleList = List("A","B","C","D","E","A","L","M","N") val exampleMap = ...
Hima_93's user avatar
  • 51
0 votes
2 answers
50 views

I have this function: static int[] AddArrays(int[] a, int[] b) { Array.Reverse(a); Array.Reverse(b); int[] result = new int[Math.Max(a.Length, b....
Punzicul's user avatar
2 votes
1 answer
229 views

The problem I am facing: I need to find a way to deal with very large sets (3 to 10000000) of positive and negative ints, this seemed relatively impossible based off of previous experiments. However, ...
Talon Van Vuuren's user avatar
1 vote
1 answer
2k views

I tried the binary search on the 2D matrix and I got the solution which gives the time compexity to be the O(logN.logM). There exist already a solution which performs it in log(MN) time. I Only want ...
Mohit Ashliya's user avatar
2 votes
2 answers
2k views

This is one of the most unique and fun sorting algorithms on planet earth, in which the time required to complete sorting depends on the size of each individual element rather than the number of ...
Chinmay Krishna's user avatar
-1 votes
1 answer
826 views

I was solving a leetcode problem , and wanted to find the space complexity[1] of a function that receives a 2D array of size nxn, and in the function I initialize a new 2D array of size (n-2)x(n-2) ...
Hasan S.'s user avatar
0 votes
1 answer
220 views

I want to calculate the moving sum of a list of integers with a window of size 3. I have a class as such: class MovingSum: def __init__(self, window=3): self.window = window def ...
turtle_in_mind's user avatar
-2 votes
1 answer
765 views

Given this input: const paths = ["src", "src/components", "src/components/index.ts", "src/utils", "src/configuration/config.ts", "another/file.ts&...
User's user avatar
  • 151
1 vote
2 answers
94 views

Let's say I have M boxes of different colors and sizes. I need to find a set of N boxes that contain different combinations of colors and sizes. For example, the user could say they want the final set ...
Mike R's user avatar
  • 961
0 votes
1 answer
166 views

I am trying to visualize a sorting algorithm with react, my algorithm works fine but i want to link it to divs on the DOM that change their height as the sorting algorithms sorts a given array, i have ...
Coder apprentice's user avatar
2 votes
2 answers
2k views

I have a Spark dataframe in the following form: > df1 +---------------+----------------+ | vector1| vector2| +---------------+----------------+ |[[0.9,0.5,0.2]]| [[0.1,0.3,0.2]]| |[...
Hilary's user avatar
  • 485
0 votes
1 answer
89 views

I have a program written in JavaScript that runs CRUD operations depending if the items in one lists are different from the other. Basically comparing two lists, main list and mirror list. The ...
Ian Matsumoto's user avatar
0 votes
2 answers
58 views

I'm working on building an algorithm that sorts in place for an array of nondecreasing integers, and it's not passing some of my tests. I was wondering why? I've included a sample input and output as ...
Candace's user avatar
  • 53
1 vote
1 answer
242 views

I work with 3-dimensional arrays of fixed size. For the first time I used passing by value. fn some_func(matrix: [[[f64;Z];Y];X]) {// body} fn main() { let m = [[[0.0;Z];Y];X]; some_func(m); }...
Alexander Fyodorov's user avatar
2 votes
0 answers
1k views

Given an array L containing N elements, from an alphabet of M distinct elements, is there an effective way to calculate the minimum number of swaps of two adjacent elements such that we group all the ...
rmlb's user avatar
  • 21
1 vote
1 answer
152 views

public int longestConsecutive(int[] nums) { Map<Integer, Boolean> numMap = new ConcurrentHashMap<>(); Map<Integer, Integer> maxMap = new ConcurrentHashMap<>(); ...
user avatar
0 votes
1 answer
249 views

you are given an array of triplets of size N, we have to choose one number from each triplet, forming a new array of N size, such that the GCD of the numbers in the new array is maximum. example: an ...
ayushi's user avatar
  • 63
0 votes
2 answers
208 views

The input is a multi-line string containing the matrix: input = '''22 13 17 11 0 8 2 23 4 24 21 9 7 16 7 6 10 3 7 5 1 12 20 15 19''' I have to replace all the occurrences of, let's say 7 ...
Abhinav's user avatar
  • 119

1
2 3 4 5
7