I have this function in c++ that finds longest common prefix for all strings in Trie.
I need to change it so that it returns maximum longest common prefix between pair od any 2 strings in Trie. Can you help me, how to do that?
string findLCP(struct TrieNode *root)
{
struct TrieNode *pCrawl =...
I have read a lot and spent a lot of hours trying to reach the right way to set a good htaccess in order to redirect an HTTP site to HTTPS.
There are a lot of tutorials on the Internet, even on Stack Overflow, but some of them seem to be outdated and don't meet good SEO practices.
The scenario ...
My question is flagged as off-topic:
Lacks concrete context.
How can I improve this question?
The //... in the edit history is added to tell viewers that it might or might not have more properties, since it's against the rule, I removed it. But even without it, the code still works without...
Imagine you have a table stored some sparse vectors by the pair of (dimension,value), for example.
+------+------+------+
| id | dim | val |
+------+------+------+
| 1 | A | 1 |
| 1 | C | 2 |
| 2 | B | 1 |
+------+------+------+
Now, you want get a table of all v...
I am working on a little complicated shell script for the first time and below is what it should do:
During startup, it figures out what is my clientid by looking at host-mapping.txt file. If I cannot find clientid for my hostname then I need to exit from shell script with non zero status code ...
The code here I have is a bi-directional bfs search, given any two points in a matrix having 0's and 1's, I would like to find if there exists a path between them.Also note that it is forbidden to enter a cell that has a value of 0.I am new to python please ignore if there is a bad coding style.
...
I solved this problem using a Class, but thought I might try to figure out this memoization thing.
Problem
There are two printers that print pages at different speeds (X, Y).
What is the minimum amount of time it takes to print (N) pages?
Input Data First line contains the number of ...
I am developing an online shopping site.
This is a simplified version of my architecture.
I have a class Item, which contains all the common attributes of all products (I will explain the IItem interface at the end)
// all products common attribues
class Item: IItem {
int price { get; set...
As a follow up to this first attempt to create and use my own IObservable<T> implementation, this is version 2.0. The goal has been to correct the code where there were conceptual misunderstandings and to take the issues pointed to by answers into account.
The overall concept is the same: A sch...
@freestyle if your "ternary monster" is strictly structured, so it only ever nests at the leftmost side, you can indeed (ab)use it to write an expression in a functional style. With a decent formatting, I'd probably be fine with it in a code review -- as long as it's obvious what's done here. I'd still prefer the procedural style as this is what a C programmer later modifying code expects and understands, so it reduces the risk that bugs are introduced later. As soon as your nesting is arbitrary, a "ternary monster" will be utterly incomprehensible anyways. — Felix Palmenjust now
I am pretty new to OOPS and Python and I have implemented a scenario to create a car company and its models in python.
Is it correct to define a class just to hold variable when you can't use inheritance as in below scenario.
class CarCompany:
"""
Stores all the information Car Manu...
i have an application have been build using .net 2005 and Oracle Client ver 10 for connecting to oracle db. i upgraded it to vs 2012 and used oracle client ver 11.
now there is a query return no rows while using adapter although it was giving a result and even i'm getting result when copying qu...
I am also pretty new to Python so I want to show my code for a very small currency converter with an Tkinter GUI.
The code does what I want, but now I want to optimize it and find new "next level" topics for me to learn. So I would be happy if some of you could take a look on my code and please ...
The padding in the chat top bar (seen in non-room views, e.g. all rooms here) is off under "My Communities" list, and achievements dialog:
and...
Happens with Chrome latest stable version (65.0.3325.181) under Windows 7 and 10.
Can this please be fixed?
My Search Engine
This tool will allow you to search for a term across a set of text sources.
The user puts in a search term and the tool will check the contents of a set of text files and tell you
which ones contain the search term. The files that have the “strongest match” against the search
ter...
Many questions of new users lack some parts or common style of the site. There already are some meta questions that aggregate tips on this issue but letting new users walk through all of them is probably very discouraging.
Instead I would propose to make a community wiki question and answer wit...
I'm not sure what you mean, a question has to be 100% on-topic. The title can be used to close a question if, for example, it says "Please fix my code. Broken!". However it's mostly just used to draw people in :)
Yep! I understand, that titles like "ARGH, U PLZ HELP FIX THATH, WILL YA?" are bound to be closed (still find them funny though) I am looking for some "word play" in title. Just wan't to know, how much of it I can use.
@Vogel612, I'll read checklist once again, just to be sure
martineau & rayryeng - Thank you for the tip. I posted the question on Codereview. Zeta - Thank you for your opinion. I also agree with you! @Aja - Thank you for the suggestion! Did not think about it this way but you are right. Thanks! — J. Baselier23 secs ago
I am not a good coder so I hope you can help me out with this one. Please look at my code. I use this code to convert characters to code which is send over to a computer. This code is interpeted as HID keyboard code. I have 2 questions:
1) When code is executed, double signs like "AAA" or "111" ...
"Requires sponsorship" is what you are looking for
You can also go through the tried and tested routes: LinkedIn and Reddit
Though, with no disrespect to you at all, I feel that your biggest obstacle in emigrating to the US will not be finding the job, but the US government letting you be sponsored due to your nationality
So.. don't focus on the US
Emigrating to the US is pretty difficult if you're a new employee as it stands (I've done a lot of research into this over the past couple years :))
No, actually. I already work and live outside of the UK. But I'm looking to be transferred to our LAX office.
In order to have that happen, I'd need an L1 visa, which is one of two common work visas given to tech workers. L1 visas are for transfer visas inter-company and are only available to workers who've been with their company for a year. The alternative is H1B which most people know about but is much harder to get (they are lotteried and in high demand)
There might be some weird stuff happening there, however thankfully the Good Friday Agreement between the UK and Ireland means that I have freedom of movement between both countries independent of EU citizenship due to something called the Common Travel Area
..Unless the UK decides to put a hard border between Northern Ireland & Ireland and kills that agreement. Then I'm boned.
You're looking for Dijkstra's algorithm or at least a variation of it. While I'd love to help you with the current question I absolutely suck at math. Here's some similar questions that may help you 1, 2. — Andrew38 secs ago
This displays chart widgets in tabs. Is it possible to make the code shorter. It gets the type from django widgets.
Could I make a function that gives the tabs title and type and loops through it 3 times (flows,packets and bytes) and if yes how exactly
<h1>Protocols Statistics</h1>
<ngb-tabset>
@GertArnold the first half of your statement is incorrect. Just because existing code is not buggy doesn't mean the question is off-topic here. See also. — Andras Deak39 secs ago
I am trying to move a rectangle around with the keyboard and believe my code to be correct but for some reason when I run the code the rectangle doesn't appear and only the green background is displayed.
Could this be because I haven't used my header file correctly in linking my two .cpp files ...
the GFA stipulates there cannot be a border between NI & Ireland, but there has to be a customs border somewhere. If there isn't one between NI & Ireland, then it has to be between the UK & NI and NI must remain in the customs union. The problem with that is the DUP, keeping the UK gov in power, do not want a border between UK & NI. lol :D
I'm drawing a player on the screen. He's running in the right direction. To accomplish this, I'll need to update his position, and for that, I'll need some timing. I'll also need some timing if I plan to have a running animation for the player. Is this code any good and why not? :-)
class TimedO...
I have two sets of resource files.
Example.
Resources.resx ,
Resources.fr-CA.resx,
Resources2.resx,
Resources2.fe-CA.resx.
Can I override the code so that I choose between Resources and Resources2 based on the some preference and make locale selection work as it is?
@PanagiotisKanavos Thanks for your comments. I will check with Type.GetTypeCode.. Actually I need to convert into switch case as per code review comments.. — Bhrathi11 secs ago
I'm developing a basic application with following classes and I'm really confused about their design. Sometimes I feel them over-engineered other time they are just too dumb.
Would you kindly see if there is any problem with it ? or how can I improve it
//Classes
Model Class /* hold static da...
# importing all the required components, you may also use scikit for a direct implementation.
import copy
import math
import random
import time
import sys
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import decimal
#used for randomising U
global MAX
MAX = 10000.0
#us...
Are eloquent transactions meant to only contain db-query related code? Or can their be other code that runs within the transaction?
In other words, if I want to make a call to an external web service to create some object, and only make changes in the database if that call succeeds, can I do tha...
What is the time complexity of my program? I think that my program runs in a \$ O(2^n) \$ time but since I'm using a Hashtable to store and re-use subproblems to resolve the main problem, it should be less time since we do less recursions. Help me please!
import java.util.Scanner;
import java.ut...
Introduction
I drive a white 2CV from home to work, and intend to keep that way
until retirement. Once retired, I will sell the 2CV to buy a yacht and
sail away. My home is far, far away from my work, so I put a lot of
kms on the 2CV everyday. The 2CV is beautiful and nice but also ...
When I 'group by' or 'group_by rollup' I getORA-00979: not a GROUP BY expression
I get the desired results by using select distinct.
Is there another way to do this without using select distinct?
with tree_row as
(
select 'PLUM' as tree_name, 'BACK40' as tree_location, 'MON' as tree_harvest...
@Peilonrayz it is a programming challenge to them, to see if they can do it...they may not have read the tag description before putting it onto the question
I have something like this:
lib/
somecode1.js
somecode2.js
somecode3.js
...
somecoden.js
__tests__
somecode1.js
somecode2.js
somecode3.js
...
somecoden.js
Each test file is something like this:
const somecode1 = require('../somecode1');
describe('Test cases fo...
@Malachi I don't really see what the tag description has to do with it, as they look like a standard challenge. I'm just curious where it's from, to potentially have a go myself.
I know what you mean, however I've done a couple of challenges that have read the same way. I see there's a comment asking where it's from, so I guess we'll find out soon enough :)
I could argue that I believe this question is OK for SO, but I'm open to taking it elsewhere. And seeing how there hasn't been a quick and simple answer (what I thought it would be) here, I can see how it might fit better over at Code Review. Please flag my question for closure if you feel it doesn't belong. — Scuzzlebutt23 secs ago
If you save it in context then you would access it via this.context. A better question would be: Why didn't var _that = this; pass code review? That is a fairly standard practice. — nurdyguy26 secs ago
Interesting the _that doesn't pass code review but the misuse of concat() does pass. Question should be about the code review! — Randy Casburn1 min ago
"didn't pass code review" - surely your reviewer told you which alternative is preferred. If he didn't, ask him - not us. — Bergi26 secs ago
I've been trying to rewrite the perl transliteration function in javascript. This isn't a complete replication, and I haven't looked at the perl source code... I took inspiration from this question for my source code.
some unit tests (not all):
describe('without flags', () => {
it('should pr...
@Malachi For starters, all SQL should be accompanied with a schema. We meta'd that.
Irrelevant.
Please tell us more about what this query accomplishes, what the schema looks like, and provide a sample of the data. See How to Ask. — 200_success39 mins ago
i guess I'm an "intermediate" programmer and I wrote this framework to run commands on an imessage group chat using a third party websocket to send and receive them. The general basis of my code is:
initialize data
read from the websocket until a "newMSG" event is received
initialize users and ...
A span provides a view to a contiguous piece of memory.
Internally a span wraps a pointer, and a size.
I tried an existing implementation: gsl-lite. Somehow a function like template <typename T> void f(gsl::span<const T>& s) {} can't accept a gsl::span<T> as an argument. There seems to be no im...
I'm finishing C Primer Plus by Stephen Prata book and I wrote as a part of the homework program to convert binary string to decimal number:
#include <stdio.h>
#include <string.h>
typedef unsigned char byte;
typedef unsigned int uint;
int strbin_to_dec(const char *);
int main(void) {
char ...
I just started creating a poker web app. It's still in it's infancy and I just have a basic range board and I was wondering how my react code was. This is the first thing I've ever written with react, feel free to get very nitpicky.
https://bitbucket.org/daneholmberg/poker-helper/src/master/
So I am trying to learn how to properly set Class attributes of a Python class, and wondering about using class functions to do so.
My beginners way has taught me to do:
class MyClass():
"""MyClass class instance"""
def __init__(self, project, version, command):
self.project = p...
@Mast Do you perhaps have experience with returning products to Alternate.nl? I plan to buy a VR headset but I cannot be 100% sure that I don't get sick or anything, as far as I know returning an item shouldn't be an issue though
actually second-hand market might even be better right now but nah, was planning to buy ti from Coolblue.nl though but it's sold out :(
Or take any shop and pay using PayPal, enforce policy by threatening to reclaim money.
I've used that trick before on a shop I didn't trust. Turned out to be a wise move.
> Given a simple SQL statement, and a stored procedure call that accomplishes the same task, the simple SQL statement will always execute faster. Why? Because with the stored procedure, you not only have the time needed to execute the SQL statement but also the time needed to deal with the overhead of the procedure call itself.
After three days for research, I discovered that CallableStatements are much slower than prepared statements because there is overhead when setting up the stored procedure. That's why my stored proc takes 300ms+ vs the prepared statement.
This explains the issue:
As you may recall, CallableS...
Technically, the SP is always slower, but if you let the optimizer be the optimizer, it can often do the SP quicker in the end because it knows what it's got, vs. being handed unknown SQL every time.
Basically, SQL does weird stuff, including something called "parameter sniffing", it's easier to sniff and optimize SP's than regular queries, because everything has to be parameterized.
@Phrancis Queries do the same thing if you parameterize them / use prepared statements, but if you have anything hard-coded that changes, all bets are off.
@Mast Basically, yeah. :)
SP's do better and more effective sniffing 99% of the time, and I doubt you're doing anything to be put in that 1%.
@SirPython Hey, I just timed the new widget on the office network (the old time was on my home network). Time-To-First-Byte is consistently under 700ms.
i found a question on stackoverflow using promises, an answer has been provided but for practicing purposes i thought about proposing an alternative using async / await and i'm wondering if its a good idea,
is it a good idea to replace the promises in the the post with async / await ?
what wou...
I have a task to create a view that will add a column which checks if data in two rows of one table matches the same two rows of another table.
I have these tables:
Table 1
Name ID Team
John 35 1
Josh ...
So I've been trying to make a blackjack game as my first attempt at an OOP project. The program is working, but not yet finished as it is lacking three major features that I couldn't figure out how to implement.
Not being able to deal the same card more than once
Automatically changing the valu...
I build a RESTful CRUD API with Node.js and Express. This application allows, for example, to create a table on the client side with the ability to add, update and remove data by ID.
I generate an array of random data for the availability of data when you start working on the client side with the...
@TnTinMn It is okay to recommend the OP post on CR but in the future, please don't use Code Review as a reason to close a question. Evaluate the request and use a reason like too broad, primarily opinion-based, etc. Then you can mention to the OP that it can be posted on Code Review if it is on-topic. Please see the section What you should not do in this answer to A guide to Code Review for Stack Overflow users — Phrancis58 secs ago
I am fairly new to Python. I have spent some time trying to implement this and wanted to ask the community for some advice.
I am receiving an index out of bounds error. I would like help addressing that as well as any advice on a way to write this code more efficiently because mine is very rough...
Example:
[1,2,4,5] output would be [1,5] and [2,4]
So here is what I tried but code breaks at one point need help with decision making at that point.From below code if(avgArr1 < avgArr2){ is the point where I decide which needs to be the source array which needs to be destination array for inse...
I created JS CRUD table with the ability to edit with popup.
This is part of the code for editing.
Editing includes the following steps:
click button "edit" in the row of the table with selected data
open popup window with showing data in the input fields
edit data and confirm this by clicking...
I don't think this is a code review, but I do think the question itself is missing. I'm assuming they want the text from within the html pulled out as a string, but I'm not sure. @perusjosh, if that is the case, please add the jquery you have tried, and also add some clarification so the question is clear. — Tylerjust now
The following code animates an item's Y position based on how much of its parent is currently visible. This is the first time I ever animated something on JavaScript based on the window scroll position and the current performance is extremely bad. I am looking for ways to get this running as fast...
If you want your code to be reviewed, then you should post it in codereview.stackexchange.com also post your code in your question, just linking to somewhere else will irritate people. — Pablo16 secs ago
@Pablo It is okay to recommend the OP post on CR but in the future, please don't use Code Review as a reason to close a question. Evaluate the request and use a reason like too broad, primarily opinion-based, etc. Then you can mention to the OP that it can be posted on Code Review if it is on-topic. Please see the section What you should not do in this answer to A guide to Code Review for Stack Overflow users — Phrancis22 secs ago
Let assume a table has more than 100 of columns & I want to display all the rows when all of its columns (Col1, Col2, ..., ColN) are nulls except for the column(s) I mentioned (PK).
This is just a sample table I created to explain this question.
Sample Table with data
╔════╦══════╦══════╦════...
I am evaluating if a list of pathways and its genes has pathways included in another pathways. So the way I thought about it is to create a function that does just a single comparison.
all_in <- function(x, y) {
if (length(x) > length(y)) {
0
} else {
ifelse(all(x %in% y), 1, 0)
}...
Here is an attempt at implementing the simplest Neural Network, which is an algorithm for learning a binary classifier. In this specific case, it can decide whether an input, of a pair of Cartesian coordinates, belongs to some specific class or not.
main.cpp
#include <iostream>
#include <iomanip>...
Hello guys this is an assignment due tomorrow and i've done all the questions But i want you guys to chek my code and see if there are parts i can change to better my code . Please. so here is the questions and below what I've done. Thanks for taking your time and helping me.
A company decides t...