# Tag Info

2

Style review I think numberOfGuys should be a parameter obtained in the main args, so that you respect the possibility to obtain n from an external source. As pointed in the comments, don't do isTrue = false, that's... weird. True is always true, period. You could rename it hasRemainingGuys or something like that. Data structure Using an ArrayList ...

1

Performance Time complexity for your algorithm is $O(N²+N²/2)$. If you find a way to combine Transpose $O(N²)$ and ReverseCols $O(N²/2)$ in a single run, you could get $O(N²)$ in worst case. Edit: given Henrik's good eye, you have already come up with a solution before that adheres to the optimized complexity. So, apply it here.

3

Guard conditions ArgumentNullException is typically thrown on incorrect usage of the API. It is not an end-user exception, so I would not bother with an exception message. throw new ArgumentNullException("A string is required"); throw new ArgumentNullException(nameof(s)); // perhaps rename 's' to 'input' or 'value' For the ArgumentException instances ...

7

I'll try to cover the response part. SingleProduct and BundleProduct should be polymorphic. ConcretePrice, DiscountedPriceByAmount, DiscountedPriceByPercentage should be polymorphic. I think they are talking about the following: you need to have a table of products and a table of prices this is not exactly a requirement, but I guess this would be a ...

3

successor(node, targetValue) does not necessarily return the in-order successor even if called with a node in a valid search tree and that node's value: what about search trees where a value can occur more than once? I notice no docstrings. successor() in a binary tree (I could guess that much from left and right) might be the in-order successor, ...

4

For idiomatic Python: You should not put spaces between the brackets and the values in function calls. You should use snake_case for variables. You've said you have concerns over finding the parent node that is the ancestor. Lets say we have the tree: A B C D Since that all left nodes are smaller than the current value in binary trees we know that \\$...

2

I took your code and rewrote it a bit, so that it satisfies my personal requirements for production-ready code. if (args.length < 2) { System.err.println("usage: Task <arg1> <arg2>"); System.exit(1); } I removed the throw new Exception since passing the wrong number of arguments is not a programming error but a wrong invocation of ...

0

Usually, we throw an exception if some pre-condition or assumption we've made about the code is violated. So unless processResult assumes/requires that the two string arguments will be equal to do its job, I wouldn't throw an exception. When the program is as small as this, it could be okay to change the initial check to: if (args.length != 2 || ...

0

I believe your code will work based on what you provided. However, I would recommend a couple of changes. T1 does not need to be part of the result set as you do not retrieve anything from it. Since it is only used to filter, I've moved it to an exists clause. Avoid expressions on the data field when comparing to a static or known value. It takes a bit ...

5

Your query could be simplified. use inner join to avoid ambiguity when reading the query temporal interval join date between start and end (inclusive end) join business_calendar as bc on (bc.date_begin < d.dl_valutation_date or bc.date_begin = d.dl_valutation_date) and (dateadd(day, 6, bc.date_begin) > d.dl_valutation_date ...

7

There are some basic considerations to make in your design. Guard arguments Perform at least NotNull checks on arguments on public entrypoints of your API. public OrderDeliverer(Warehouse warehouse, IOrderStreamer orderStreamer) { this.warehouse = warehouse; this.orderStreamer = orderStreamer; } public OrderDeliverer(Warehouse ...

4

I looked through your code, but to be honest, I don't see much to review. Believe it or not; That's actually a good thing. I think. You're basically using two libraries in two classes. But you haven't paid much attention to structuring your own code. You could, for instance, have take a bit more effort in the validator class, splitting it up in methods ...

0

From the problem statement, we could lay out classes like below: class Product { private String name; private doublt price; //Getter setter, constructor etc } class Book extends Product implements NonTaxable { ... } class Food extends Product implements NonTaxable { ... } A product can be: interface Taxable { float taxRate(); } Or, it ...

Top 50 recent answers are included