Category "arrays"

Checking whether space should be printed in the middle or at the end in for loop?

I am trying to give info to my program whether it should print space or not. My code looks something like this, and its printing spaces at the end (which is not

function loop for more than one times java

so basically i tried to call method that return array from other class java, it works perfectly except it double the size or length of the array 2 times from or

How to apply a function to a 2D numpy array with multiprocessing

Suppose I have the following function: def f(x,y): return x*y How do I apply the funtion to each element in an NxM 2D numpy array using the multiprocessi

Find Duplicate Elements In Array Using Swift

How to find Duplicate Elements in Array? I have array of phone numbers so in the phone numbers i should start searching from the right side to the left side and

Sorting an array of strings in C++

I am trying to accomplish the following task: List the students in alphabetic order, sorted by last name. Do not change the given case of the names. Do not ch

Combine multiple columns into an array as one of the key in a results set

I am having trouble placing data into its right structure. I have a result set data of: array ( 0 => array ( 'company_id' => 1, 'company_ab

How to shuffle strings in arrays in golang?

So I created a program to help me decide which game to play. Before I start my problem let me show you my code: package main import ( "fmt" "strconv"

How can I convert a buffer of a slice of bytes (&[u8]) to an integer?

I am reading raw data from a file and I want to convert it to an integer: fn main() { let buf: &[u8] = &[0, 0, 0, 1]; let num = slice_to_i8(buf

How to find the largest number(s) in a list of elements, possibly non-unique?

Here is my program, item_no = [] max_no = 0 for i in range(5): input_no = int(input("Enter an item number: ")) item_no.append(input_no) for no in item_

PHP array stringify

In a lyrics application I'm coding, I'm using an array to print an artists table. The artists array looks like this: $artists = [ [ "Avril Lavigne"

Check if one element exists in an array of objects

I have the following array of objects: var memberships = [ { id: 1, type: 'guest' }, { id: 2, type: 'member' } ]; How can I verify if

String.join array from last element

I have a scenario where I am getting a comma separated string LastName, FirstName. I have to convert it into FirstName LastName. My code is below: Public stat

Google Sheets linking two sheets using a primary key

I have two sheets that I want to link using a "primary key". At the moment, I have imported from sheet1 into sheet2 some columns using the function =Sheet1!A1

MySQL Filter JSON_CONTAINS Any value from Array

I have a JSON field in a MySQL database that contains values like [1,3,4,7]. I would like to be able to easily supply another array from a PHP variable and det

Javascript - Generating all combinations of elements in a single array (in pairs)

I've seen several similar questions about how to generate all possible combinations of elements in an array. But I'm having a very hard time figuring out how to

Move a child array to parent array and change parent/child name

I know probably this was asked before not sure if was in this form but I did tried some replay from what I found here about this and failed. ok I have this arr

TypeScript enum to object array

I have an enum defined this way: export enum GoalProgressMeasurements { Percentage = 1, Numeric_Target = 2, Completed_Tasks = 3, Average_Milest

Solve almostIncreasingSequence (Codefights)

Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from th

PHP array sort and remove duplicates by two field values

I have an array structure like this [0]=>array(3) { ["Number"]=> "L1" ["Location"]=> "Location-A" ["Qty"]=>"1" } [1]=>array(3

List within single quotes [duplicate]

I have a list which is in single quotes. '[{"Name":"name1","value":"value1"},{"name":"name2","value":"value2"}]' I receive this as an input p