instruction stringlengths 71 95.1k |
|---|
This is an update of the code for my previous post (which has now been removed as this code is more efficient and accurate) for the GeeksForGeeks task.
Task outline
Given two arrays, print all new arrays of even length where each subsequent element in the new array comes alternately from A then B and each element is la... |
Given a matrix you shall stripe the matrix, such that every number that has equal distance to the matrix border will be filled into an array.
For examples see code comments.
typedef int matrixOptimizationValue;
/*
Striping a matrix by packing numbers who have the same distance from matrix border.
Note that the packing ... |
Task
Old mobile phones had the ability to type characters by pressing a number. The letter a could be typed by pressing 2 once. The letter b could be typed by pressing 2 twice.
Given a sequence of numbers, give all possible letter combinations.
For example: The number 23 could give an output ad, ae, af, bd, be, bf, cd... |
https://leetcode.com/problems/last-stone-weight/
We have a collection of rocks, each rock has a positive integer
weight.
Each turn, we choose the two heaviest rocks and smash them together.
Suppose the stones have weights x and y with x <= y. The result of
this smash is:
If x == y, both stones are totally dest... |
I am working on a basic blog application in Codeigniter 3.1.8 and Bootstrap 4.
The application allows Registration (as an author), Login, adding Categories and Posts.
I have created an installation process for the application: after creating a database and providing its credentials to the application/config/database.ph... |
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 writing (in my code move method) can be executed only by one thread at a time
I also have to make sure that while writing updates, only the single writer thre... |
This is a follow up question of Classic Tetris implementation for Windows console - Initial Version Review
Since the changes this small project of mine suffered after applying all the excellent advice given to me in previous thread were substantial, it seemed to be a sensible idea to open it for review once more and co... |
This is a Leetcode problem -
Let's play the Minesweeper game
(Wikipedia,
online game)!
You are given a 2D char matrix representing the game board. 'M'
represents an unrevealed mine, 'E' represents an
unrevealed empty square, 'B' represents a revealed blank square that has no adjacent (above, below, left, right... |
I tried to apply for software engineer - intern with this task, and there is no reply since I sent it, so I guess I failed. Can you give me a direction in what way I should improve my code?
Task: The point of this task is to create a service, which will generate a mosaic for given images downloaded from provided URLs.
... |
This is a Leetcode problem -
Given n balloons, indexed from 0 to n-1. Each balloon is painted
with a number on it represented by array nums. You are asked to
burst all the balloons. If you burst the balloon i you will get
nums[left] * nums[i] * nums[right] coins. Here left and right
are adjacent indices of i. ... |
lodash.isEmpty([{}]) returns false even though the object contained in the array is empty.
I need something that considers these kind of nested objects empty too and wrote the below recursive function. It looks a bit ugly and doesn't use any JavaScript specific tricks. Any comments welcome.
export function isDeepEmpty... |
I'm testing the Stripe payment API. I couldn't find a Python wrapper that provides asynchronous requests so I'm writing one. My first goal was to implement the async equivalent of stripe.PaymentIntent.create.
I used aiohttp client for my tests. One implementation detail: the Stripe API can take HTTP requests containin... |
I am learning more about python using the book "Automate The Boring Stuff". The problem I completed was "Excel To CSV Converter". I want to kick bad habits to the curb, and make sure I'm learning the best python practices to further my development. I would really appreciate feedback on code efficiency, and code neatnes... |
I wrote this function that will toggle a class of a targeted element. Applying the class js_class_toggle to any element will trigger the function when clicking on it.
To define what the target element is and the class you want to toggle is, you have to add data-class-toggle="target_element_id.className" to the element.... |
Overview
I am constructing a Graph with randomly generated nodes called Positions.
The Graph has a width and a height and is represented using an adjacency list std::map<std::pair<int, int>, mrrobo::Position> m_maze;, that are open, closed, and may not have a route back to the root. I want to find a single path to the ... |
I often use the Index Match function in daily reporting tasks. I was looking for a quicker way to utilize Index Match, as I find the formula cumbersome to enter. I ended up creating a userform that allows you to pull columns using Index Match between sheets in your open workbooks.
You can download the userform files h... |
I'm trying to create a very basic compiler, and I'm working on the lexer.
I decided to store keywords and operators in an unordered_set, and use regex to match identifiers and literals (no comments yet).
Tokens.h
#ifndef TOKENS_H
#define TOKENS_H
#include<unordered_set>
#include<string>
namespace AVSL
{
enum clas... |
I currently have a dictionary (Duplicate_combos) that has a unique identifying number for the key value and the value is a list with two elements, a company code and then either a yes or no (both of these values are currently stored as strings). I am essentially just trying to see where the company code is equal and th... |
I have been working on this thread pool for awhile to make it as simple to use as possible. I need some tips on improving performance, and some good ways to test its performance. I was wondering if anyone had any opinions/suggestions!
Here is the class:
#pragma once
#include<thread>
#include<vector>
#include<queue>
#i... |
What this tool does update skills for agents on a Contact Center Cluster (Cisco UCCX). The tool reads a csv file called agents.csv from the current working directory. This file has a list of agents and their skills. The skills are updated using a REST API.
Note that UCCX allows a maximum of 400 agents, so that's why I... |
I've created a JS snippet to enhance markdown at display-time with KaTeX math rendering. (Specifically, this is mostly for documentation of math-heavy libraries where the host language documentation tool doesn't have specific math support (e.g. rustdoc).) The snippet itself is the HTML in <head> to load the KaTeX scrip... |
To practice my JavaScript skills, I wrote a phrase scrambler. I would appreciate feedback on code efficiency and readability, as I want to know the best practices for further development.
function scramble() {
let phrase = document.getElementById('phrase').value;
phrase = phrase.split('');
let newPhrase = "";
l... |
I've implemented a thread pool in C++17. This is not backwards compatible with C++14, due to the usage of std::invoke_result, which is new to C++17.
The focus of this question is on best practices, with the (hopefully) obvious observation that I really want to know if any of this is Looks Funny™ (i.e., any weird moves ... |
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can
see that the 6th prime is 13.
What is the 10 001st prime number?
How can I optimize this code?
#include <iostream>
bool is_prime(int num)
{
for (int i = 2; i <= num/2; ++i)
{
if (num % i == 0)
{
return false;... |
import threading
import os
import sys
import time
l=0
length=[]
def File_Opener(keys,l):
for lines in keys:
l = l + len(lines)-1
length.append(l)
l=0
if __name__ == "__main__":
start=time.time()
f=open(sys.argv[1],"r")
print "File to be anaysed is %s" %sys.argv[1]
Threads=[]
keys... |
I wrote this code.
It works, but I think there is a more elegant and Pythonic way to this task.
Groupby and count the different occurences
Get the sum of all the occurences
Divide each occurrence by the total of the occurrences and get the percentage
#Creating the dataframe
##The cluster column represent centroid l... |
This is a Leetcode problem -
Given an unsorted array of integers, find the length of the longest
consecutive elements' sequence.
Your algorithm should run in \$O(n)\$ complexity.
Example -
Input: [100, 4, 200, 1, 3, 2]
Output: 4
# Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its... |
I wrote a little program that adds and subtracts some algebraic expressions.
In my code (2 x 3) represents \$2x^3\$.
The purpose of this post is to get some feedback; moreover, I would like to know how to make it perform better and improve it.
I ran this program on a Mac with SBCL + Emacs.
(defun compute (exp)
(cond ... |
In the \$k\$-shortest path problem, we are searching for (at most) \$k\$ distinct, shortest paths connecting two given terminal nodes. You can see the previous version here. This implementation, however, represents the intermediate paths in the open list as linked lists so that extending such a path by one node runs in... |
I was intrigued by this question on SO and was able to come up with a reasonably efficient answer, but I'm interested in learning about further optimizations. You can certainly look at my answer to that original question for some explanations of how I've implemented certain logic, but I'm happy to answer questions as w... |
I implemented the LSDD changepoint detection method decribed in [1] in Julia, to see if I could make it faster than the existing python implementation [2], which is based on a grid search that looks for the optimal parameters.
I obtain the desired results but despite my best efforts, my grid search version of it takes... |
This was a small project I did the other day because I wanted to explore a solution to hot-reload some files in another project.
My requirements were:
Act in it's own thread
Be able to watch specific file extensions
Work on Windows
So since I knew my application would only run on windows I decided to use WinApi.
I a... |
I wanted to test my performance optimizing skills, and so wanted to find how fast I could get the first \$n\$ prime numbers. I limited myself to only the standard library, as I'm sure numpy or another library written in C has a prime generator way faster than Python ever will be - and offloading to a library doesn't re... |
This is a task taken from Leetcode -
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
/** Explanation: Since intervals `[1,3]` and `[2,6]` overlap, merge them into `[1,6]`. */
Example 2:
Input: [[1,4],[4,5]]
Output: [[1,... |
I'm working with product codes, so a user can only scan these type of product codes into a textarea element.
I don't know if my code is written the best way possible, or has good performance.
I'm using a whitelist solution for preventing bad entries.
It saves into file all product codes after 3 seconds of last keyup.
I... |
I am trying to implement a parent WebContent class and child classes to grab HTTP responses from the actual website entities. There are highlevel codes below and I am wondering what are people's perspectives in terms of the neatest way to implement this in a OOP manner.
import requests
from onelogin.api.client import O... |
This is a Leetcode problem -
In a 1 million by 1 million grid, the coordinates of each grid square
are (x, y) with \$0\$ \$<=\$ x\$,\$ y \$<\$ \$10^6\$.
We start at the source square and want to reach the target square.
Each move, we can walk to a 4-directionally adjacent square in the
grid that isn't in the giv... |
I'm working with a large enterprise SQL Server database with dozens of tables that are used mainly as lookups to populate dropdown lists, etc. These tables all follow the convention of having (table)Name as the string value of the item. For example the State table has a StateName column with values like California, Flo... |
Got caught up with this morning's C++ question.
So I thought I would have a go.
SO here is my attempt at printing the first 1001 primes.
#include <iostream>
#include <vector>
#include <cmath>
bool isPrime(std::size_t num, std::vector<std::size_t> const& primes)
{
std::size_t max = std::sqrt(num);
for(auto cons... |
I've been trying to practice more Python recently so I decided to try and make different simple text-based game programs. I'd hope anybody could help me see how to make the code neater or more efficient in any aspect.
import random
words = []
guessed_letters = []
word_guess = []
joined_word = None
def fill_list():
... |
I decided to try and write a Brainfuck interpreter in C as an exercise. This could have been written in one file, but I decided to split it up into a State "class" and an some interpreter methods.
An example test-run with a ROT13 implementation in Brainfuck:
const char* source_buffer = // Code in above link. Read from ... |
I have created this generic calendar class which I call a TimePeriodGrouping. It can contain a series of interlocking time periods (i.e. years, months, days, hours...). When time is added to one of them, it recalculates to match the proper period. Also, since seconds start at 0 and months start at 1, it also accounts f... |
How is the logic, efficiency and can it be improved?
This is a snippet from my .bashrc file, I just wrote it.
The code is supposed to do this:
Backup my .bash_history file if it is 1000 lines or less from the defined size of HISTSIZE=100000 and HISTFILESIZE=100000 lines, then backup the file.
Check if .bash_history is... |
I'm making my WebApi project.
My logic is, the controller didn't see data. It only triggers a service that returns objects to it. My simple method from TaskService looks like this:
public Task TakeTaskByUser(int taskId, string userId)
{
var task = this.GetItem(taskId);
if (task != null)
{
if (task.... |
We use the architecture shown in the code below to initialize the DB context for our MVC 5 project using entity framework 6
We have the following questions related to it:
Is it safe to initialize the Context in the constructor and use it throughout the class?
What are the disadvantages of the given approach?
Construc... |
I've been trying to solve this problem for some while and the solution I have come up with exceeds the lime limit by 1-3 ms and 2 out of 10 tests get a memory issue error. Why is that? This is the code for my solution:
#include <fstream>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
... |
This is a Leetcode problem -
The demons had captured the princess (P) and imprisoned her in the
bottom-right corner of a dungeon. The dungeon consists of M x N rooms
laid out in a 2D grid. Our valiant knight (K) was initially
positioned in the top-left room and must fight his way through the
dungeon to rescue ... |
I am preparing for an interview and came to know about this question: implement a vector class in C++. I thought of how I would write it an interview and included the code below. The things I know I did not cover already are:
1) No use of templates for different data types
2) No use of iterators for iterating.
My point... |
I'm in a project that's currently using vue. I'm at the moment developing validations for the inputs and in a way to make them more flexible, my idea was to create an intermediate component "Group Component" where I set as a property the input I want to load. As such, validations are imported in the component.
I've fou... |
How can I optimize this code of adapter's overriden method getItemCount() into simpler form?
@Override
public int getItemCount() {
return super.getItemCount() == 0 && data != null ? 1 : super.getItemCount();
}
|
In Entity Framework Core we can have recursive entities. But we cannot do an "Include" for these recursives (can we?). So I wrote a Get-method that does it for me:
First, this is my RecursiveEntity<T> base-class:
public class Entity : IEntity
{
[Key]
public int Id { get; set; }
}
public abstract class Recursiv... |
Background
I implemented the historic std::dynarray according to the specification under the name dynamic_array in C++17. dynamic_array doesn't attempt to get allocated on stack storage.
The most interesting part is the allocator support. Unlike other containers, dynamic_array does not take an allocator as a template p... |
I want to get a result from the website when I submit a form. There are several things that can go wrong.
In a simple scenario I want to return:
true - when form was submitted
false - when form wasn't submitted
null - when we don't know if form was submitted or not
I did that ugly try, because of NullReferenceExcept... |
The premise of this program is to use the least amount of vehicles to allocate the available load.
What I did is allocate the largest amount of load on the truck that fits better.
This program's intention is not to optimize a load. I.e. if I have a load of 24, the program does not use two 12 capable vehicles, but the 3... |
That is a simple program to hide text messages in text files. I'd like to hear any advices to improve my code and style.
Some notes:
There is no error handling to simplify the program. It is not a «real» program anyway. There is many assertions instead error handling.
I wrote my own implementations to strdup and strre... |
Do 3 arrays contain a common element, if they contain output it.
For example: [1,2,3], [2,3], [2,4] -> answer = 2
let arr1 = [1, 3, 11, 32, 44, 99];
let arr2 = [4, 12, 15, 99];
let arr3 = [4, 11, 13, 15, 23, 43];
function searchThreeSameNum(arr1, arr2, arr3) {
let i = 0;
let j = 0;
while (1) {
if ... |
Description
I had to create a dictionary structure where one value can be referenced by several keys.
For example the keys a, b, c reference the value 1 and d, e reference the value 2. If two groups of keys intersect then I want to merge them, for example the group a, b and b, c should result to a, b, c.
I also need an... |
I am creating fake data using faker.js. Out of simplicity I created a for-loop.
const faker = require("faker")
const dataLength = 10
const productArr = []
for (var index = 0; index < dataLength; index++) {
productArr.push({
name: faker.commerce.productName(),
category: faker.commerce.department(),
pric... |
Classes in Python do not have native support for static properties. A meta-class can rather easily add this support as shown below. Are there any problems programmers might experience if they use this implementation?
#! /usr/bin/env python3
class StaticProperty(type):
def __getattribute__(cls, name):
attrib... |
I wrote the following code for the Collatz exercise: The Collatz Sequence
Any feedback is appreciated.
Write a function named collatz() that has one parameter named number. If number is even, then collatz() should print number // 2 and return this value. If number is odd, then collatz() should print and return 3 * num... |
I have the following working tic tac toe program. Someone said it's a convoluted mess and I'm looking for pointers on how to clean it up.
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Random;
import java.util.Arrays;
public class Shortver{
private static final int boardRowDim = 3; ... |
I have a set of nested functions that I need to call multiple times. I know scipy.quad is pretty fast, but I will need to call the integrator recursively and want to remove as much overhead as possible.
I know I need to pre-allocate the arrays for some of the base functions at the bottom half of the code to get a spee... |
SQL Server 2016 introduced some JSON features, but they're far from robust. As far as I can tell, there's no way yet to output a simple array; everything must be in "key": "value" format. I don't want to do what some answers propose and write a partial JSON encoder within SQL.
Therefore, I'm stripping out certain keys ... |
Background
The Pythagorean theorem asserts that for a right triangle with hypotenuse \$c\$ and other sides \$a\$ and \$b\$, the area of the square placed upon \$c\$ is equal to the sum of the areas placed upon
\$a\$ and \$b\$. This is normally written algebraically as \$a^2+b^2 = c^2\$.
One way to prove this is to ... |
How is the logic, efficiency and can it be improved?
This is a snippet from my .bashrc file; I just wrote it and I've tested it and it almost works. This was the first version review.
I feel I haven't fully gotten a grasp of what I've done at the end of the code, could you help me understand the logic and improve it; d... |
On an overly abused workbook we've hit the limit and NumberFormats can no longer be added. If we do want to add more we need to consolidate current formats. My code requires a reference to Microsoft Scripting Runtime as it uses the Dictionary class. Is there anything I can do to further improve performance?
I started b... |
I recently did a interview with WalmartLabs. I was tasked with a take home assignment. I didn't sign a NDA and a team at WalmartLabs said I could post the code on GitHub. I was tasked with developing a program that would deliver orders in such a way to maximize customer satisfaction. My approach to solve this problem w... |
Well, I'm trying to generate the following:
Input:
Level1a/Level2a/Level3a/Level4a
Level1a/Level2a/Level3a/Level4b
Level1a/Level2a/Level3a/Level4c
Level1a/Level2a/Level3b/Level4a
Level1a/Level2a/Level3b/Level4b
Level1a/Level2a/Level3b/Level4c
Level1a/Level2a/Level3c/Level4a
Level1a/Level2a/Level3c/Level4b
Level1a/Level... |
Hi I have a simple tcp server, and that server receives messages with specific length so basically i need to wait for TcpClient to fill buffer with that amount of data, and it works.
But I am not sure if this should look like it looks as I am writing this in f# and still learning:
let private WaitForData (client : Tcp... |
Calculate the number of loans issued by the Regional offices for each business week in the period from 38 to 40 business week of 2011 inclusive. Sort by name of the regional unit, business week.
dataset and snippet here - http://www.sqlfiddle.com/#!18/53151/4
Are the joins correct in this query?
DDL:
create table ter... |
I am writing a function to decode data from a run length encoded format like:
{
dataGroup: {
count: [4, 4, 2, 1],
dataOne: [1, 3, 2, 1],
dataTwo: [7, -1, 9, 0],
dataThree: [3, 8, 1, 2]
}
}
to
{
groupName: {
dataOne: [1, 1, 1, 1, 3, 3, 3, 3, 2, 2, 1],
dataTwo: [7, 7, 7, 7,-1,... |
I've got a working solution for an onMouseOver event which rolls over a set of images and replaces them in the element. Due to my lack of knowledge in JS I would like to know if this is a proper solution. It works in Chrome and Firefox.
The solution sets attributes (i.e. isRunning="true", isCanceled="true") , reads th... |
The task is taken from LeetCode
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
Example:
Input:
[
1->4->5,
1->3->4,
2->6
]
Output: 1->1->2->3->4->4->5->6
I'm struggling with the solution as none of them seem to be very fast:
My solution 1
/**
* Definition for... |
I finished my university project for calculating \$1/\pi\$ and I would love to get some feedback.
Before you guys jump into this code please keep in mind newcomer to C++ just decided to use it for this project because I assumed libraries will be better than others in terms of arbitrary precision.
Few words about the pr... |
I created a code that import the data regularly into a selected workbook. The code run well, it takes less than 20 seconds before the data is imported successfully.
How does it work?
I get a monthly data with Excel format. I want the data to be imported into my workbook to be analysed further.
Step by step
The first ... |
This is a simple gravity simulator coded in Python 3.7 using Numpy and Pygame. I was wondering if it can be optimized further. Initially I had coded it using pure Python lists, using nested loops to calculate forces between each body, but then the good people of Reddit suggested me to use Numpy, Cython or Numba to impr... |
Function queries data from an Aurora database. Aurora database is the MySQL engine therefore, I'm querying it with a MySQL NPM module. If there is something better, I'm all ears.
The calling function has a try-catch block to manage exceptions. This function just connects to Aurora, submits a query, and displays the res... |
I have \$10^5\$ to \$10^6\$ points on a sphere, and want to choose some points from them which are as close as uniformly distributed as possible. For that reason, I do the following: at each step I add the point in the data which is farthest away from any point which I have already chosen. In order to do this, I find t... |
This code takes in input as audio files (.wav or .WAV) and divides them into fixed-size (chunkSize in seconds) samples. Then these chunks are converted to spectrogram images after applying PCEN (Per-Channel Energy Normalization) and then wavelet denoising using librosa.
My concern now is how to improve the performance ... |
Based on my previous attempt.
Prime Sieve and brute force
Trying to make the interface simpler I have moved all the code into a class. This way I can keep track of the primes and inc and the next value to look at. This way I can control accesses to isPrime() so it can not be called on values directly (as it makes the a... |
I'm working on a responsive login page (open source). Could you try to review a bit the code on Github ?
body{
font-family: "Montserrat", sans-serif;
margin: 0;
background-image: linear-gradient(to right bottom, #ff0000, #ff5600, #ff8000, #ffa200, #ffc200);
}
#title {
font-size: 60px;
margin: 0;... |
I have two modules, Notification which basically contains SignalR hubs and CoreSetup which contains core setup logic in it.
I have a class in CoreSetup module which keeps track of employee location . I want SignalR hubs to be notified and those locations to be on MAP when new data are inserted through Web API.
I don't... |
I am writing a program that will take images in a folder, get the GPS Coordinates (from the EXIF data), then return the closest "major city".
(I define a major city as one with an airport, so technically I'm taking the GPS coords of an image, and finding the closest airport and returning that city)
I've looked at thi... |
Background: I'm trying to create functionality that would display two layouts of the same data. The position and size each data record must be independently saved per layout and each layout will have different functionality and be displayed in a different way (one will display the records as squares, the other circles)... |
I am writing an HTTP client for terminal, similar to curl, as a learning exercise.
There's one limitation it suffers from and that is that it won't return until the client closes the socket. I fixed this problem with a hack by setting the socket to timeout after 1 second, but I feel like there has to be a better way.
... |
Scenario: Return a String that contains only alphabets without spaces.
input = "A man, a plan, a canal: Panama"
output = "AmanaplanacanalPanama"
Can you please critique my code?
private String OnlyAlphabets(final String string) {
StringBuilder sb = new StringBuilder();
char ch;
for (int i = 0; i < string.l... |
I am fairly new to python, been coding in it for about a year or so. My company is switching from using SAS and a Netezza database for some of our data management. In order to access certain information, I have to load .dat.gz files now using Python3 in unix. In order to access similar information I used to access usin... |
I just finished making an implementation of a SHA256 hashing function (https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) in Rust and I was looking for some feedback.
As far as I can tell it works properly, but I haven't used Rust before so I'm looking for some advice regarding the style. Performance advice wo... |
C++17 introduces std::invoke which calls the exposition-only INVOKE. Here is an implementation. This isn't a large amount of code, and it is to a large extent a transliteration of [func.require].
I took the liberty to add invoke_r which calls INVOKE<R> since I find it quite useful at times.
// C++17 std::invoke impleme... |
My program opens a website and downloads a text file. The text file is a simple file with one word per line. I save the file to local disk and then create a list to hold each line of the text file for later processing. I would like to know if I am doing these first steps in a way that would be considered idiomatic Py... |
Someone asked here how to determine a function is being called from multiple threads. My take on this is that they are asking about concurrent access not sequential access. The accepted answer therefore seems inadequate. Detecting concurrent access is also a problem I need to solve for debugging purposes so I thought I... |
I'm developing a web app that will be used privately by a company (no need for SEO and old browsers support).
I made some interactive components (calendar, file manager, etc) that I am not sure if I implemented them properly. I use the simplest of them (contact picker) as an example here.
I'm wondering if I should make... |
I have C# code that makes some calculations for physical models. I have this project class:
public class Project
{
public IEnumerable<GenericComponent> components;
private ValueService valueService = new ValueService(Guid.NewGuid().ToString());
public Project(string norm)
{
components = Factory... |
Question:
There is an Exam_Merge table into which to import
records from a similarly structured table in another database.
In this case, the Exam_Merge table contains the values of the primary key ID
from another database, but this field is not unique.
For some reason, some of the entries in it were duplicated:
an entr... |
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:
Input: l1 = [1,2,4], l2 = [1,3,4]
Output: [1,1,2,3,4,4]
Example 2:
Input: l1 = [], l2 = []
Output: []
Example 3:
Input: l1 = []... |
QUESTION: Choose the name of clients,
concluded more than one loan agreement in 2010,
as the numbers and dates of issue of these contracts.
Sort by name of the client and date of issue of the loan.
My question: Is it the correct way of solving this task?
Sqlfiddle: http://www.sqlfiddle.com/#!18/c140c/1
DDL:
create tabl... |
Here's an implementation of a multi-producer single consumer queue that I wanted to use with tasks such as logging from multiple points in a program to a single sink. The implementation is inspired from https://github.com/dbittman/waitfree-mpsc-queue but modified mostly to use C++17 features. Comments? Specifically:
A... |
I have written a program that takes a number n and prints Pascal's triangle having n number of rows.
Here is my code -
n = int(input("Enter number of rows: "))
a = []
for i in range(n):
a.append([])
a[i].append(1)
for j in range(1, i):
a[i].append(a[i - 1][j - 1] + a[i - 1][j])
if (n != 0):
... |
This function returns the indices of all white spaces as an array of Integer. It works fine with a small string:
func whiteSpacesIndices(value : String) -> Array<Int> {
var indices: Array<Int> = []
for (index, char) in value.enumerated() {
if char == " " || char == "\n" || char == "\t" {
ind... |
My php page displays a slider of images and when the user clicks on an image(.item), the div below (#team_single) changes the content without reloading the page. Content of the div changes also when the user clicks the arrow of the slider (.slick-prev, .slick-next, .slick-arrow).
I'm looking for a way to improve the fo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.