Category "arrays"

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

Finding union of 2 sorted arrays (with duplicates)

I'm trying to find the union of 2 sorted arrays (with duplicates) but I feel I'm not coming up with the most elegant code (what I have works btw, I just feel I

Decimal To Binary conversion using Array and Stack

This is the C Program I have written to convert a Decimal number to it's equivalent Binary number. I have used Stack (implemented using array) and the following

PhP how to calculate moments with variables rows

I have 45 - 50 array rowss that are deserialized json return values in standard PhP array string format, from cURL with data that looks like the following: Arr

javascript - schedule with tabs

I created I javascript schedule thermostat for a enteire week and work. But now I have some problems with tabs, because when I move a period, moving on slider,

Sum all odd indexes in an array

I have to complete a program according to these instructions: public class SumOddIndex { public static void main(String[] args){ int[] array = {1,1,

Sum all odd indexes in an array

I have to complete a program according to these instructions: public class SumOddIndex { public static void main(String[] args){ int[] array = {1,1,

Codewars Challenge - Count of positives / sum of negatives

My code works but it's not being accepted in order to pass the challenge. Any help on what I'm doing wrong would be appreciated. Challenge Description: Given