We changed our privacy policy. Read more.

Questions tagged [comparative-review]

This tag is used for questions which present a problem and multiple solutions, where the asker wishes to know which solution is best (and why).

83 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
1answer
3k views

Merge Two Sorted Lists in JavaScript

The task is taken from LeetCode Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example 1: ...
4
votes
0answers
138 views

Java multithreading many readers one writer implementations

I have a shared data object with writer threads and reader threads. Number of threads can read from the shared data at the same time (in the code getmethod), and ...
4
votes
0answers
264 views

Two solutions to leetcode 127.wordLadder

I am working on Word Ladder - LeetCode Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such ...
4
votes
0answers
451 views

Parallel solutions to N Queens Puzzle

I'm trying to increase the performance of my N Queens Puzzle solution. I'd find some threads on SO already but they don't appear to help me to increase performance. My best solution, however, is a ...
4
votes
0answers
36 views

Validating a collection of proxy servers with maximum possible throughput

I am validating a collection of proxy servers and trying to achieve the maximum possible throughput. I've tested a few different methods, such as Task.WhenAll, TPL ...
4
votes
0answers
170 views

Get nearest driver from 2.5 millions of data using mongodb

I have created 2.5 millions drivers dummy data, in this case lets say the drivers are moving around in the city. The driver's document look like this : ...
4
votes
1answer
143 views

Time(n) Complexity of Fibonacci Algorithms

It is my first use of classes in Python. I wanted to create something useful and try some new things as I learn this cool language: strategy pattern, testing with nanoseconds precision, curve/poly ...
3
votes
0answers
40 views

class uploade file(photo,video,..) laravel

I am working on a project, the previous programmer used this method to save photos, videos, etc. ...
3
votes
0answers
53 views

React Higher Order Components - export wrapped component or wrap it in parent?

I've been learning about about how to use context, and how to make a higher order component to provide context values through props. So, I've created my HOC to pass down the props, and it looks like ...
3
votes
0answers
74 views

Providing a connection pool

I need some opinions about method naming and single responsibility principle. First of all, let's talk about method naming. The class below was created to provide a connection pool and whenever a pool ...
3
votes
1answer
198 views

In Memory Database in Unit tests, isolate the tests

I have stumbled across these unit tests in a code review that are using in memory db: ...
3
votes
0answers
57 views

Simple beginner Rust CLI file reader that prints to stdout

Q: Am I approaching writing idiomatic Rust code correctly? Hi CodeReview, I'm a beginner Rustacean coming from Python going through Rust books (The Rust Book, Rust in Action). A lot of the beginner ...
3
votes
0answers
76 views

SageMakerTrainingOperator in Airflow

I have made an operator (surrounded by others operators) for training a model in sagemaker in airflow and I have doubts how would it be more readable or more pythonic. First I did this: ...
3
votes
0answers
554 views

Kadane's algorithms to leetcode "121 Best Time to Buy and Sell Stock"

I employed the conventional Kadane's algorithms to solve a maximum subarray problem in leetcode Best Time to Buy and Sell Stock - LeetCode Description Best Time to Buy and Sell Stock ...
3
votes
0answers
484 views

Export EXIF data from thousands of images to CSV

I have written a script that retrieves specific fields of Exif data from thousands of images in a directory (including subdirectories) and saves the info to a csv file: ...
3
votes
0answers
81 views

Best path using some intermediate points, where cost is either x-axis or y-axis distance

We are given N Cartesian points \$(x, y)\$. Anytime we move from \$i\$-th point to the \$j\$-th, the move costs \$\min\left(\left|x_i - x_j\right|, \left|y_i - y_j\right|\right)\$. The problem is to ...
3
votes
0answers
227 views

Python code for a basic AI with voice recognition for retrieving news articles

I wrote a program for a basic AI with voice recognition that makes request to News API to retrieve metadata for the headlines currently published on a range of news sources and blogs. For now it does ...
3
votes
0answers
370 views

Two reimplementations of the Underscore _.reduce function

I am working on rewriting the underlying code for some Underscore.js functions. Re-writing the reduce function has been causing a lot of headaches. I have been able to re-write it two different ways, ...
3
votes
0answers
78 views

Methods to add and check elements in a Bloom Filter

I have a working Java implementation of Bloom Filter. These are the methods to addElement and check for an element. ...
3
votes
0answers
685 views

Comparing linear time strongly connected component algorithms in Java

So I have implemented three linear time (\$\mathcal{O}(V + E)\$) algorithms for finding strongly connected components of a (directed) graph. A strongly connected component is just a maximal subset of ...
3
votes
0answers
116 views

Custom MySQL duplicate_key update queries

The goal is to create an activity or update its counter if it's already present. And to be super accurate, the code avoids race conditions with a custom ...
3
votes
0answers
279 views

Print the nodes of binary tree column-wise, using recursion and iteration

I am trying to code for both recursive and iterative approach to a problem. Below is a recursive code to print the nodes of binarytree column wise. Basically I have count of root as 0 and if I move ...
2
votes
0answers
36 views

Which of my string indexing functions in Kotlin is semantically closer to my Java one?

I have a working string indexing method in Java and did convert in Kotlin. All methods shown below produce the same result but as I am really new to the Kotlin language I wanted to ask which of my two ...
2
votes
1answer
64 views

Efficiently use array values and variables in a WordPress template

Is it better to validate and put an array value into a variable at the top of a file or to check the array value directly right before output in the file? I work at a WordPress shop and we have a ...
2
votes
0answers
31 views

What is a better practice in bash scripts to test if string is empty: [[ -z ${value//[0-9]/""} ]] or ! [[ ${value//[0-9]/""} ]]?

I test in a bash script if a variable value contains digits only. There are two options, both give the valid results: ...
2
votes
0answers
73 views

Why does my Clojure implementation of Conway's Game of Life run so much slower than my Java implementation?

I'm trying to learn Clojure coming from a Java background. I have written a simple implementation of Conway's game of life in both Clojure and Java, trying to keep the overall structure of the code as ...
2
votes
0answers
166 views

generic implementation approaches for a recursive function

Let's take the famous fibonacci problem as an example but this is a generic problem. Also, taking scala as the language as it's rather feature-rich. I want to know which solution you'd prefer. we all ...
2
votes
0answers
35 views

Snake string implementations

This snippet uses a string as an output. As we iterate through the input string, I just keep appending a character to the string and I know this just pretty much creates a new string everything I add ...
2
votes
0answers
136 views

Angular forms - reactive vs. [(ngModel)]

I am developing this angular app and it has big forms with 100 + fields. I was thinking about using [(ngModel)] without reactive forms, so that it's easier to do ...
2
votes
0answers
30 views

Fast algorithms in Javascript for shortest path queries in directed unweighted graphs - follow-up

(See the previous iteration.) Now I have reworked my pathfinder program, and I ended up with this: ...
2
votes
0answers
61 views

Composing commands to control virtual machines

I created a function which takes some inputs and builds a specific set of strings. The function is working as intended, however I can't help thinking how ridiculous it looks every time I see it. I ...
2
votes
0answers
10k views

Accessing child class variables from its parent class

Requirements The code should be able to call a parent method to read and modify child object variable that is referenced by a pointer inside the Child class. This code is to be run on an embedded ...
2
votes
0answers
281 views

Which JavaScript snake-game implementation is better?

I was sort of bored and wondered how that Youtuber (Max Wihlborg) implemented his snake-game, so I went on and took a look at his code, and then I and edited his code. I made some minor changes, but ...
2
votes
0answers
16k views

Reset an input field after submission

i have some issues dealing with a simple case in my redux-react app: i want to reset an input text after an asynchronous operation ignited by a button. Let’s say we have an input text in which you ...
2
votes
0answers
2k views

HackerRank - Matrix Rotation

Problem statement Given a matrix (up to 300 × 300), rotate each element R steps anti-clockwise along concentric rectangular paths (R up to 109). The algorithm is rated as hard on HackerRank. On ...
2
votes
0answers
80 views

Simple JavaScript module to manipulate CSS

After posting some of this code on Stack Overflow I was told to have a look here and get some feedback. I am having fun building a light JavaScript framework and have copied this pattern. It works ...
2
votes
0answers
392 views

Comparing three packet routing algorithms via simulation in Java

Inspired by my question Simulating a random packet routing algorithm and printing packet statistics in Java I decided to implement two more packet routing algorithms: one that computes all the ...
2
votes
0answers
56 views

Retrieving the most recent posts from the users someone is following

I have two different implementations for retrieving posts from the users someone is following and I want to know which one you would recommend using. First I'll show you the tables, and then the two ...
2
votes
0answers
146 views

Better way to toggle between the state of show() and hide() in jQuery

I have the following code which switches between the states of hide() and show() of show prices ...
2
votes
0answers
749 views

Interactive transition between view controllers

I have made an interactive transition controller in Swift in two different ways. This interactive transition controller is the parent class and I have few child classes which adapt the parent for ...
2
votes
0answers
391 views

Updating a list of a few dozen document resources in MongoEngine

This is my model: ...
2
votes
0answers
65 views

Rewriting authentication controller using promises

I am in the process of refactoring some complex code that uses callbacks to instead use promises. I am trying to figure out if my proposed approaches make sense. ...
1
vote
2answers
44 views

Comparison of 2 different ways of writing Merge Sort Algorithm

I have recently learned Merge Sort algorithm in C++ with 2 ways of writing it. 1st Way: ...
1
vote
0answers
36 views

Graph stored as adjacency list or as endpoints and intervals

I tried speeding up my Graph class, so I removed the Node class and Edge class, and decided to use arrays and ArrayLists. My 2 implementations seem very similar, ...
1
vote
1answer
50 views

Changing an element in a list when a predicate holds

My current project is a Settlers of Catan server in Haskell. I often manage to achieve my goals within Haskell, but the code is getting messier as the project grows. My question is about the ...
1
vote
0answers
37 views

Asking for feedback, when utilizing Pandas, why is it better to use pandas.Series than lists data type?

I found out the hard way, when utilizing pandas is better to use pandas.Series than lists data type to manipulate data. Even if ...
1
vote
0answers
27 views

Spectrograph using array-of-slice-references

I've written a working and complete proof of concept that shows a spectrograph in Matplotlib. I want to nail down this proof of concept before I continue with development, and I'm not thrilled with ...
1
vote
0answers
281 views

What is the best implementation of a ignore case dictionary In C#

Imagine we have a custom dictionary class which is derived from Dictionary<string, object>. Dictionary is case-insensitive about keys and elements arrange is ...
1
vote
0answers
550 views

Spring Boot - JPA query execution Time

Any one suggest me right way to write mapping more then one table using spring-boot (jpa), i was done it, but its required more time to extract result, Following are the Mapping of Pojo: First:- <...
1
vote
0answers
852 views

Fast matrix transpose

I would like to improve the naive matrix transpose algorithm by using a cache friendly algorithm. So far there are 4 variants. Iterate over the source matrix: ...