Category "arrays"

Find the max value of the same length nails after hammered

I'm trying to solve this problem: Given an array of positive integers, and an integer Y, you are allowed to replace at most Y array-elements with lesser val

Sort an array except one element in JavaScript

I have an array and I am sorting it but I need to sort everything except one element of my array. My array is: var Comparison = [ {key: "None", value: "No

Trying to find "magic combinations" in MongoDB

I have two MongoDB collections in a database named "records". Here's a sample document from the first collection: course_completions { "_id" : NumberInt(1

How to take 2D array inputs from command Line arguments in java?

I have to take inputs from the command line and assign them to a 2X2 array. Input = 1 2 3 4 (from cmd line) output = 1 2 3 4 int a[][] = new int[

debug an array of linked lists in c

I'm having a trouble in my project, at first I made one linked list and it worked properly but then I had to edit it and make it an array of linked list, but it

Array.prototype.filter() expects a value to be returned at the end of function array-callback-return

I am trying handle below code and its showing enter image description here const toArray = props => (props && props.split ? props.split(',') :

Codewars Challenge - JavaScript - Find the first non-consecutive number in Array

Link to Codewars challenge This is very basic, but for some reason, I can't figure out why I'm not able to return null when there are not any non-consecutive n

Is there a way to convert an Object[] array to char[] array?

class Solution { char[] make(String s){ Stack<Character> st= new Stack<Character>(); for(char c:s.toCharArray()){ if

C# - Random Generator exclude last number from Array

I've just started my first little project in C# and with WinForms and I am stuck on this one feature for a few days now.. I have an Array with about 60 PictureB

How can I create a 2D array of chars with POINTERS in C?

I'm trying to create a program which the user inputs the number of items (rows) and give each one of them a name (scanf) with the max of 30 characters. I want t

Show total number of selected filters array of items in React

I have the following problem. In widgetFilters array (length===3) i want to show the numbers of selected items in the header of the Filter. const [selectedFil

Output how many duplicates in an array

I'm looking to output the number of duplicates for each int in an array e.g. the array 1,2,3,4,1,1,3 would output 1:3, 2:1, 3:2, 4:1. at the moment no matter ho

Inserting a new element to array

So my goal is to join two Arrays together and insert the new size of the new array in the beginning of the array.

Filtering array with Boolean giving unexpected results

I can't understand why the output is 17 its only returning the true values not the false values either that the false value are boolean also function countSheep

How can I use optional chaining with arrays and functions?

I'm trying to use optional chaining with an array instead of an object but not sure how to do that: Here's what I'm trying to do myArray.filter(x => x.testKe

How to loop and display array of objects and their nested arrays

I need help, I got stuck on objects with multiple nested arrays. I have a json file which consists of object, that holds array of objects, and these objects hav

Reverse each word with uppercase without changing word

How do I reverse each uppercase and lowercase ("I am A Great human") to ("I ma A Taerg namuh")? This is the code I Have: function wordsReverse(str) { let wo

Create new numpy array by duplicating each item in an array

I would like to create a new numpy array by repeating each item in another array by a given number of times (n). I am currently doing this with a for loop and .

Creating a limited count array of custom type

I am creating array of Promises of type [MSGraphScheduleInformation?]. I want to limit the array count to 4, but the repeating param in the API is throwing erro

Declare an array in TypeScript

I'm having trouble either declaring or using a boolean array in Typescript, not sure which is wrong. I get an undefined error. Am I supposed to use JavaScript s