Data dodania Pytanie
2018-02-14 07:02 Swift how does my function exceed O(n)? »
I am trying to work on a leetcode problem that asks for Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appe...
(1) odpowiedzi
2018-02-13 16:02 Iterate through 2d array of booleans and leave only the largest contiguous "2D blob of ones" »
Ok, so the question is kind of awkwardly phrased, but I hope this will clear things up. I have this sample 2d array. $array = array( array(1, 0, 0, ...
(3) odpowiedzi
2018-02-13 04:02 Multiple sort numeric before string »
I would like to know how to sort numeric before string. I use array_multisort to sort my array. There is my sample data $arr = [ [ 'comp...
(2) odpowiedzi
2018-02-11 16:02 Seperate num to elements »
I'm trying to 'separate' a number into X elements. I mean, if my number is 12 and my desired element count (X) is 6, I want to separate for each elem...
(2) odpowiedzi
2018-02-11 14:02 Java - Check if array is sorted descendant »
I need to check if array was sorted strictly descendant. I wrote following code public boolean isSortedDescendant(int [] array){ if ((array.lengt...
(1) odpowiedzi
2018-02-08 01:02 Finding the odd number out in an array »
I am trying to solve a problem where I'm given an array, such as [0, 0, 1, 1, 2, 2, 6, 6, 9, 10, 10] where all numbers are duplicated twice, excluding...
(8) odpowiedzi
2018-02-06 12:02 Implement tail-recursive List operations »
I fear I've missed something "standard" but I did try, honest! I have been trying to understand how to implement efficient, tail-recursive, operation...
(3) odpowiedzi
2018-02-06 04:02 Group array of items by their distinct id »
How do I go about re-arranging my array to by organized by shirt size: [ { shirt_id: 1, size: "small" }, { shirt_id: 1, size: "medium" }, { shi...
(2) odpowiedzi
2018-02-05 11:02 Python - inefficient spatial distance calculation (how can it be speed up) »
I am currently trying some geocoding in Python. The process is the following: I have two data frames (df1 and df2, houses and schools) with latitude a...
(2) odpowiedzi
2018-02-04 20:02 C++ time spent allocating vectors »
I am trying to speed up a piece of code that is ran a total of 150,000,000 times. I have analysed it using "Very Sleepy", which has indicated that t...
(1) odpowiedzi
2018-01-31 20:01 Java boolean-algorithm to check wheter number of digits is even »
I´m trying to write a recursive method that returns true, if the count of digits of n displayed as a binary number is even and false if it is odd. I ...
(4) odpowiedzi
2018-01-30 18:01 How does this put implementation work with q instead of p »
We are implementing the put part of Algorithm A from Functional Programs for Generating Permutations (Topor, 1982). This is our implementation. It pas...
(2) odpowiedzi
2018-01-30 07:01 Faster way to get substring in python? »
I am coding Skew Algorithm to construct the Suffix Array and I have a long string (length >= 4000). In Skew Algorithm, I have to construct the Triples...
(3) odpowiedzi
2018-01-26 22:01 Why my Binary Search implementation in Scala is so slow? »
Recently, I implemented this Binary Search, which is supposed to run under 6 seconds for Scala, yet it runs for 12-13 seconds on the machine that chec...
(1) odpowiedzi
2018-01-25 13:01 Comparing computational speed of these two short codes »
In the two versions of the code, both v1 and v2 are large vectors (length ranging from 1,000 1,000,000 with len(v1)=len(v2)). I expected code 2 to be ...
(2) odpowiedzi
2018-01-24 18:01 Efficiency of Sieve of Eratosthenes algorithm »
I am trying to understand the "Sieve of Eratosthenes". Here is my algorithm (code below), and a list of features that I cannot understand (in order). ...
(2) odpowiedzi
2018-01-23 21:01 How to count the number of reduced proper fractions fast enough? »
I am currently solving a mathematical problem in which I need to count the number of reduced proper fractions with both numerator and denominator more...
(6) odpowiedzi
2018-01-23 20:01 Faster way to read/write a std::unordered_map from/to a file »
I am working with some very large std::unordered_maps (hundreds of millions of entries) and need to save and load them to and from a file. The way I a...
(5) odpowiedzi
2018-01-20 20:01 Recursive and random grouping a list »
I'm trying to write a function which creates dichotomously grouped list, f. ex. if my input is as following: [a, b, c, d, e, f, g, h] I want to ...
(2) odpowiedzi
2018-01-20 03:01 Implementing unification and skipping variables »
I'm working on an implementation of the usual unification algorithm in the usual way: recursive descent through expression trees, adding variable bind...
(2) odpowiedzi
2018-01-18 14:01 Optimized argmin: an effective way to find an item minimizing a function »
Let us say I've got a collection of items and a score function on them: struct Item { /* some data */ }; std::vector<Item> items; double score(...
(3) odpowiedzi
2018-01-06 17:01 How Python execute [list] * num? what's time complexity and memory complexity? »
I am new to Python. I was recently confused by a syntax "[list] * k". I want to understand how Python actually executes it. Example: >>> l ...
(1) odpowiedzi
2018-01-05 13:01 What's the best way to enumerate permutations of deck of cards? »
I'm looking to make a function that would assign a value to a specific shuffle of cards. The function has to be bijective. The deck has 52 cards so ...
(1) odpowiedzi
2018-01-04 17:01 Dynamic Programming with Scala »
To practice Scala I wanted do solve simple dynamic programming exercises with Scala. For some exercises I already wrote a Python implementation. Using...
(3) odpowiedzi
2018-01-03 17:01 High performing container for storing a high number of objects »
I am looking for an ideal data container for with following objectives: The behavior of the container must be sort of like Queue, with the following ...
(2) odpowiedzi
2018-01-02 14:01 Finding the longest substring regex? »
Someone knows how to find the longest substring composed of letters using using MatchCollection. public static Regex pattern2 = new Regex("[a-zA-Z]"...
(6) odpowiedzi
2017-12-31 16:12 Jquery bubble sort on a table »
I have got this table that has rows of numbers. Now I want to create a jQuery function that'll sort this table once th is clicked and I want to do tha...
(2) odpowiedzi
2017-12-31 01:12 Understanding this polynomial division algorithm in a functional language »
**This is an algorithm that is implemented in a rather archaic language, standard ML. I have difficulty understanding this algorithm: fun polyquotrem...
(1) odpowiedzi
2017-12-29 09:12 Get minimum Euclidean distance between a given vector and vectors in the database »
I store 128D vectors in PostgreSQL table as double precision []: create table tab (    id integer,    name character varying (200),    vecto...
(2) odpowiedzi
2017-12-22 22:12 How to find smallest positive integers to make digits monotonic? »
I found a programming problem I was unable to solve. I have been given a set A of integers. For all numbers x in A, find the smallest positive integer...
(2) odpowiedzi
2017-12-20 01:12 Creating a pair of its order, value in a list in python »
Let's assume that we have a following list: [3, -1, 2, 100, 5] (this is just an example, could be any list containing real numbers of arbitrary len...
(5) odpowiedzi
2017-12-19 18:12 javascript - find subset that gives maximum sum under a certain limit (subset sum ) »
I have an array with some integer values, and I need to get a subset of them that gives me the maximum sum that is inferior to a given value. So let's...
(3) odpowiedzi
2017-12-19 01:12 QuickSort and MergeSort performance on Sequential data fit in memory vs Slow to Access Sequential data on disk »
The following quote is from "Comparison with other sort algorithms" section from Wikipedia Merge Sort page On typical modern architectures, effic...
(1) odpowiedzi
2017-12-13 03:12 BST O(NLogN) build proof »
I'm trying to study for a test and I know that a single insertion is O(logn) and the height of the tree is n, so the comparisons would make the time ...
(1) odpowiedzi
2017-12-09 19:12 How can I find the missing integer in a string of random non-repeating integers in a range »
I'm having trouble even beginning to think of how to do this. I need to find a missing number in a string of random numbers that don't have separator...
(3) odpowiedzi