instruction stringlengths 71 71.9k |
|---|
Is this a good implementation?
static int[] mergeSort(int[] arr) {
if (arr.length <= 1) {
return arr;
}
int[] left, right;
left = Arrays.copyOfRange(arr, 0, arr.length / 2);
right = Arrays.copyOfRange(arr, arr.length / 2, arr.length);
left = mergeSort(left);
right = mergeSort(righ... |
Description:
Given an image X with known dimensions. We call a method CreateThumbnail to make a thumbnail (or not) with a given max-width and max-height (both optional).
CreateThumbnail call ComputeSize method (bad name?) which is responsable for doing the following logic:
If no max-width/max-height, the width and heig... |
The basic idea is that by defining three functions--recognize, dissect, and combine--conversion between any case type is possible.
recognize is meant to recognize a string of a given case type
dissect is meant to break down a string into an array of lower case substrings according to the given case type
combine is mea... |
Is this code good? Or is it the noobiest PHP you've ever seen?
<?php
//Initialization Section
require "helper.php";
$dest = "../forms/addhandout.php";
//Check for $_POST Data
if(!$_POST) {
send(array("msg" => "ERROR: No Data Recieved"));
} else if(!isset($_POST["name"]) || $_POST["name"] == "") {
send(array("... |
I just felt a sting as for the first time, I copy-pasted code blocks, and made very little change to it, to overload it. It works fine, but I have 3 constructors that are basically copy-pasted. I'm hoping there is a smarter way to do this.
This simply creates a thread and runs it with 1, 2 or 3 arguments, and then prin... |
I have finally found some time to redo the last tic tac toe game I posted. I have gotten rid of "Magic Numbers" as well as any typos(if their are any please point them out but I think i rid myself of them...hopefully). I have updated the way the code is implemented as well as added a header titled "Constants". This cho... |
I have implemented linked list data structure in c.
linkedlist.h
#ifndef LINKED_LIST
#define LINKED_LIST
#include <stdbool.h>
struct linkedlist {
int key;
struct linkedlist* next;
struct linkedlist* prev;
};
bool list_insert(struct linkedlist** p,int k);
struct linkedlist* list_search(struct linkedlist* ... |
I am currently learning Graph algorithms by solving questions on online judges. The below code is for implementing Topological sort, using recursive DFS. Also, it is my first time with C++ STL. Kindly review my working code below and provide me with feedback. The exact question for the below code is here.
#include<c... |
The purpose of the method is to add a list of items after every nth step (5 for example) where the input items are repeated if needed. I'm looking for an overall review and possible how to remove the use of the while and replace it with a for.
public static List<string> AddEveryNthStep(List<string> items, List<string> ... |
I'm a newbie and interested in learning different data structures and algorithms. While implementing quicksort, I found this code works pretty well for partitioning.
int partition(int ar[], int lft, int rgt) {
int left = lft;
int right = rgt;
/*median of three is the best pivot value to accomplish in nlogn time*/
int ... |
I've implemented K-means clustering in Rust. It's my second Rust project (my first one is here: Randomly selecting an adjective and noun, combining them into a message)
I would like advice on whether I am doing stuff idiomatically, and any sensible optimisations I could make. I also appreciate advice on code-style --... |
Currently I am working on a profiling unit that does not require stack traces to preserve the call stack, and can return the performance in a html format.
All though the logging in itself is fairly fast (negligible overhead on each function), the visualisation of the information is not.
With a little over 25k objects g... |
I have been developing a simple login registration page with PHP using the repository pattern. Following are the business rules :
During registration
Email must be unique.
Email must be a valid email address.
User table columns:
id, name, username, password, created_at, updated_at
register.php page
if($_POST)
{
t... |
Starting point
I kind-of inherited a VBA project at work that consists of a bunch of Word document templates that provide users with the tools they need to create documents according to company guidelines and to help them give all documents the same appearance. We use different templates for the documents that we creat... |
I am trying to make an easy-to-use non-recursive make script that works with several directories.
Everything is packed here.:
Directory structure
/ - root
/bin - where executable(s) will be made
/obj - where .o and .d files will be made
/include - any external includes
/lib1 - library... |
I'm using TypeScript but this example is in plain JavaScript. I have a class rank with a child-class master. I need an ordered collection of unique masters. Here's what I have but it seems a little "kak":
function getMasters() {
var gms = [];
_.each(this.ranks, (r) => {
if (gms[r.master.id])
... |
Background:
Didn't what to have to reference bulky 3rd party lib for inline data driven tests and wanted to use standard MS testing framework.
Created helper InlineDataDrivenTest to provide a workaround for this limitation.
Usage
[TestClass]
public class DataDrivenTests : MiscUnitTests {
[TestMethod]
public v... |
I started out with the Rosalind problems a while back. Turns out it's a great way to learn a new language. I'm still trying to learn Ruby, and while I haven't managed to use regular expressions as much as I wanted to (learning those being one of the reasons I started learning Ruby in the first place), I put together a ... |
I wrote a userscript (to be run with Greasemonkey/Tampermonkey on Stack Exchange sites) to include a Prettify extension and enable syntax highlighting for a language which isn't supported by default.
I have only occasionally dabbled in JavaScript, and I have never written a userscript before:
(function (func) {
// ... |
The code is about displaying membership information of all clients from database. I was just wondering what I could do to improve/change it.
def optionA():
global DoAnother
while DoAnother == True:
print("")
member = input("Please enter the member number: ")
if len(member) !=4:
... |
At this point i am interested to see other techniques on handling session timeouts.
What are some good improvements on this script to detect when a session is no longer valid?
Important definitions:
session.gc_maxlifetime - (default 1440 seconds) defines how long an
unused PHP session will be kept alive. For example... |
Project Euler problem 10 is to find the sum of all primes less than 2 million. I have written a program that does this, and it works, but it takes an excruciatingly long amount of time. What I'm asking is if there is any way I could optimize this to make it run much faster.
I wrote it in an app on my iPad called Python... |
I have started learning Java and was trying to solve some easy problems from different websites like HackerRank and leetcode.I am relatively new to programming so please don't mind if this is too naive. I found a problem in LeetCode to rotate array.The problem can be found here
I have implemented the solution using tw... |
My code will display a Hearthstone deck list.
I'm still learning HTML and I'd like help with a few things:
• How readable is my code? How can I improve readability?
• Have I used any bad practices? What should I do instead?
• Is there any redundancy in my code?
<!DOCTYPE html>
<html>
<head>
<link href='https://fon... |
Given a text file including different text and integer numbers (text.txt), what's the shortest way of getting the sum of all the numbers out if it? I have:
import re
f = open('text.txt', 'r')
result = 0
for line in f.readlines():
for value in re.findall('[0-9]+', line):
result += int(value)
f.close()
print... |
I am working on a vertical-scrolling 2D platform game using GameplayKit, SpriteKit and I am writing it in Swift 2.0.
Today I have been working on a tiling-routine which repositions SKNode right after they have left the upper or lower screen-border. I am not spawning new SKNodes because when the game becomes very fast i... |
I want to convert a list of integers into a two-dimensional array for use with TestNG DataProvider. Here is the code I've written:
static List<Integer> studentList = new ArrayList<Integer>();
@Test()
public void testMethod(){
studentList.add(477915);
studentList.add(477916);
studentList.add(477917);
S... |
Goal:
Permute inner values between two dictionaries with matching outer key,
Save permuatations in counter,
Move to next outer key, update counter with new permutations.
Problem:
Many lookups on large dictionary (60 outer keys x 18000 inner key:value pairs) make existing code correct but slowwwww.
import collections
... |
I have a dll and an executable which both deal in configuring certain things for a much broader software solution, and the code below in particular is directly meant for database configuration. (Here "inmate info" has been substituted for the actual configurations.)
In an MVC context, the dll is essentially the contro... |
I want to know if I can improve this program. Its goal is to print a pattern in a pyramid form, by first receiving a letter. The first row is always 'A', only. Then 'ABA', then 'ABCBA'. Increasing order, then decreasing.
#include <stdio.h>
int main(void)
{
char alphabet[26] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char... |
I'm trying to put together a workflow for building Clojure applications with Boot in CIDER. To test this workflow, I've written a small example application using Seesaw. My project structure looks like this:
example
├── build.boot
├── dev
│ └── user.clj
├── .dir-locals.el
└── src
└── example
└── core.clj
... |
I'm taking a Python course and the current assignment is to create an algorithm that sorts numbers in ascending order (without using built-in sorting functions). I've had no programming experience before taking this course, so this might be a bit rough.
I got my script to successfully sort the numbers by figuring out t... |
I am working on this assignment to draw the flag of Liberia for my essentials of computer programming class.
I finished it but had extra time to kill and noticed that a couple similar blocks of code are not very concise and could be shortened with a loop, but right now I can't seem to form the code just right!
Below I... |
I've made a very simple program that takes integer number arguments either with plus/minus sign or without them, and print the number in binary format.
binary.c
#include <stdio.h>
void printBinary(int);
int toInt(int*, char[]);
int handleProgram(char[]);
int main(int argc, char *argv[])
{
return handleProgram(... |
Problem statement:
We have a number of functions in our web application that are getting called too frequently. We'd like you to create a function that, given a function and a time interval, returns a new function that we can call as often as we like, but ensures that the original function is never called more than on... |
#include <iostream>
using std::cout;
using std::endl;
class SinglyLinkedList
{
struct SLL
{
int data;
SLL* next;
};
SLL *head;
public:
SinglyLinkedList()
{
head = NULL;
}
SLL* createNewNode()
{
SLL *newNode = new SLL;
newNode->next = NULL;
... |
I'm trying to write a multiple functions memoizator, which I've talked about here. The main problem is creating a container containing different and heterogenous functions.
I found a working solution, but I don't know if it's safe, if there are limitations, if it's somehow inefficient or if there is a more elegant solu... |
I wrote a method that will return the minimum element in a linked-list that operates in O(1) time. I tested and everything works fine. However, I was wondering if there is anything that I can do to make my code more efficient or cleaner.
public class Node {
//private Object item;
Node next;
Object item;
... |
So I got sick of several things about the way TryParse works. I implemented a generic ParseOrDefault function using reflection. It appears to work as expected, but I'm not fool enough to say my code is bullet proof. What's wrong with it? If something is wrong with it, can it be fixed, or should this idea be tossed?
usi... |
I'm very new to functional world. I've written a simple brainfuck interpreter as my first F# program.
What I would like to know:
Am I using the right data structure for each situation?
Is my code easy to understand?
Is my code style similar to common F# codes (naming, organization etc)?
Is my code "very declarative" o... |
I'm still learning from designing with types non strings by Scott Wlaschin.
For my project I transform some XML to HTML with xslt.
Because every filename can have side effects, they are stored in string option types.
If I do the transformation I get an ugly pyramid of Option.map and five times more lines of code comp... |
I do parsing of the string in order to find wrapped sub-string inside brackets of the first level. a+(b+(d-g))+g+d, in this case I will need to separate (b+(d-g)). Below is the function which i use for such situations. This function is invoked when i find any opening bracket (. I did profiling of the program and unfort... |
I need to parse a space- delimited text file. I want to read the file and do operations for each cell. Here is how I am parsing the file:
String line;
BufferedReader reader = new BufferedReader(new FileReader(file));
Map<String,String> mapFile = new HashMap<String, String>(19);
while((line = reader.readLine()) != null... |
I have a script for a web page that has to initialize a lot of complex event handlers on page load. Because of the large number of events and DOM elements that these events should fire for, I want to construct a global object containing all the initialization logic.
var Global =
{
button1Handler: function (... |
This is the dirty bastard of my current code block, and I'm trying to find a way to improve this code for increased readability, but also functionality.
The method checks if the store is currently open. Yet on our site we close the sites 30 minutes prior to their real closing time. Issues arise mostly because all of ou... |
Functions with common and simple file operations have started to repeat in my code. Many like this one, but with subtle differences for example:
def do_something_with_file(file_name, access_mode, data):
with open(file_name, access_mode) as f:
f.do_something(data)
This is my solution so far:
import pickle
f... |
I have implemented Heap sort, but i think the time complexity is more than (nlogn).
Could anyone explain me; what is wrong in my code which makes more time complexity.
I will be glad if the answer is in terms of algorithm time complexity based.
import java.util.Arrays;
public class HeapSort {
public static void ma... |
Here is the link to git repo of my application I am currently implementing just to have better understanding of OOP as well as learning Concurrency (Atleast a try :D)
What is the whole simulation intends to do?
This application is intended to provide classes or interfaces to create
-> a Room in which persons can enter... |
I have played recently and implemented doubly linked list with merge sort algorithm. I was wondering if there is any way of improving the algorithm further to make it as fast as possible (I know about implementing list as array of void* pointers but I want to implement that as a separate structure).
I've gone from some... |
In our product, Company is a model that can have many Companies belonging to it; so some Companies are parents, some are children, and many are both.
We have a helper method Company.root that has as its children all Companies that do not actually have a parent; in this way, accessing Company.root and recursively iterat... |
The task is to output a representation of the matrix where the top left element is on top, the anti-diagonal is the central row and the bottom right element is at the bottom.
For example, consider the following matrix:
1 2
3 4
5 6
The diamond version of this matrix is:
1
3 2
5 4
6
which would correspond to a nes... |
Array.prototype.itemsWithQuantity = function(n) {
var counts = {};
var result = [];
var i = this.length;
while(i--){
counts[this[i]] = counts[this[i]] == undefined ? 1 : counts[this[i]] + 1;
}
i = this.length;
var alreadyPushed = {};
while(i--){
if(counts[this[i]] ... |
I have code which makes use of jQuery and some additional libraries. But the jQuery part is too overwhelming (and thus it does its job slowly). So I tried to optimize it, but had no luck. Now I'm seeking help from the community.
Here is the code, from the news page in my WP theme:
/*
CSS Reset
*/
html,body,div,sp... |
While playing around with J (link), I found that you can create a sequence of shape N0 N1 ... NK with i. taking a list as its parameters. Since i. creates a range 0 .. RHS and >: increments each value in a range, i. >: i. RHS creates a non-empty range. We can use , to flatten it and +/ to summate it. Given an RHS, thi... |
For a string, count the number of occurences of each character. If at most one character has odd count then the string can be a palindrome else it's not.
public class Palindrome {
//count the chars in the input string
//if not more than one character has odd count then palindrome is possible
... |
I'm trying to take a result set and organize it into a dictionary then assign the dictionary values to variables that are publicly accessible from my controller. My issue is I have to check if there is a key, if there is a key, assign it to a variable manually, if there isn't set the variable to 0. Is there a better dy... |
I'm updating a stats bar on the page after a user action. The code works, but as you can see, it's very messy.
Is there a shorter way of writing this function? Seems like a complete mess. I thought about using $.each a couple times to cycle through, but since I need to compare values from the first two array keys in th... |
The script below demonstrates VLOOKUP by showing which languages appear from column 1 in column 2.
Is there a way that I can refine my code to pass in an exact match? Also, I notice in my console.log, that it is iterating the for loop many times on each word that it finds. Can that be consolidated or condensed to be m... |
I am attempting to write a statistical program using an LDA model I've trained/created using Gensim. I am very new to Python and am a student level programmer. This current program is working and getting the results I want. In get_similarities I am comparing each of the user's document vector to all other user's in the... |
I am using this AsyncTask class to update two different tables on SQL Server. So far this code works fine, I'm interested in a better and more sufficient code structure for this class, specially in doinbackground().
Is it okay to call multiple webservice methods in a single thread? Any other feedback?
private class... |
I wrote a small program to compute intersection of 2D infinite lines using Boost Geometry
A line is defined by two points in Line class. The getVector method enables to extract a direction vector.
The perp function enables to compute the perp product of two vectors. A zero value means vectors are parallel.
The intersec... |
I have just finished building a Chess game in Java as an exercise. Whilst I am quite happy with the rest of the code, my castling move check code is lengthy and ugly and I want to see if there is a way to improve it.
There is a board class, which has a list of all pieces which are all unique classes extended from a sin... |
I have a recursive algorithm that inserts nodes into a trie data structure but it seems to be running not well and takes over 10 mins to complete on a data set of about 1 million. All nodes contain a syllables to a phrase all of the syllables are then inserted into the trie to allow for searching in a binary fashion to... |
I am an architecture thesis student in my final year and I am developing a piece of software that, ideally, should design houses for me based on certain input.
I got the program to work when it was in the proof of concept phase and i was just doing three rooms, but now that I added a border and a more complicated Room ... |
I have a situation where I'd like to wrap up some plain C handles into a class, with a destructor and other niceties, in C++. I would like the wrapper class to have the exact same size as the handle, so I can pass an array of the wrappers into the C api without having to allocate and translate them first.
The handle is... |
This code parses and tokenizes my shell language command interpreter. I will try and make it 2 functions, one that is the tokenizer and the other that is the rest of the function. Can you find improvements that I can make besides breaking up the function into 2 smaller functions, with a helper function that is the toke... |
Objective
Determine a factor (A) based on the leading and trailing axles that are present on a length of a surface based on an iteration from 3rd party software.
Setup
Provide an area for user to configure vehicle axle position.
User provides surface length (straight line).
User provides initial iteration number fro... |
I'm trying to learn x86 assembly and hopefully move on to projects of the scope that more than one person would be involved.
This is a (relatively) simple subroutine written in Intel x86 assembly using MASM that copies one string onto the end of another. I named it strglue to avoid conflict with the C library function ... |
My approach was to find each occurrence of the PNG's file signature followed by its end of file (EOF) and write the bytes between to a new file whose name is simply a counter starting at zero.
use std::env;
use std::fs::File;
use std::io::prelude::*;
const SIGNATURE: [u8; 8] = [137, 80, 78, 71, 13, 10, 26, 10];
const ... |
How to set in HTML/CSS a section just like in this picture https://snag.gy/mStL9H.jpg ?
I have tried something but am not sure if it's right.
#trd-banner{
background-color:#284c57;
width:100%;
height:50%;
margin:auto;
}
#list{
position:relative;
left:110px;
top:1px;
width:200px;
height:150px;
... |
I am in the process of learning data structures and I am trying to implement Binary Tree using Queue in C#.
Below are my Tree implementation classes.
public class Tree
{
public char Data { get; set; }
public Tree LChild { get; set; }
public Tree RChild { get; set; }
}
public class TreeImplementation
{
... |
I am programming this Computer Algebra System, it works fine, but I'm running into some problems where I'm writing a lot of redundant code, I'd like some advice on that.
The most problems I'm having are with Constants having the property that if they're added and are zero then the result is the thing they were added to... |
I am writing a Swift library. I'm writing unit tests for that library.
I am afraid that some of the code that I am testing will possibly throw exceptions. In Swift, we can handle errors, but we can not handle exceptions. Exceptions are considered programmer errors which should be caught and fixed before release. Th... |
I needed JavaScript inheritance that offered calling of overridden methods (super calls).
Furthermore I needed a possibiliy to add behaviour to instances (mixins).
Mixins should not only be full classes including mentioned inheritance but also be able to override its instance' method.
Below is what I came up with. It ... |
I've started to learn programming recently and it's my first more or less "big" project. But coding this project for me is quite hard. I spent a lot of time to understand what I've done and my coding is developing really slowly. And I'm curious what's my problem? Is it my lack of experience or is it my ugly style of pr... |
The code below takes integer n as input, and delivers a list of all primes up to integer n using the Sieve of Eratosthenes.
My question is, could you please help me optimize this code? Is it considered poor code to use 'try' flow control? I'd like to optimize the code such that I don't need it.
def factorfinder(n):
... |
# Program will display a welcome message to the user
print("Welcome! This program will analyze your file to provide a word count, the top 30 words and remove the following stopwords.")
s = open('Obama 2009.txt','r').read() # Open the input file
# Program will count the characters in text file
num_chars = len(s)
# P... |
I'm working with 3D point clouds stored in Numpy arrays. I'd succesfully used the scipy's KDTree implementation for task like k-neighbors search and outlier filtering.
However I wanted to try the octrees as an alternative data structure for other task like downsampling.
I was looking for an octree implementation in Py... |
I am doing a code wars problem and so far I have managed to loop through a collection to find the "winner" (defined by the String that appears more than collection.size()/2). However, my code times out and isn't efficient enough. How can I make this more efficient?
import java.util.List;
public class BallotsCounter1 {... |
I'm just getting into bash and sh scripting. I mostly just stub out little convenience or exercise scripts for myself, but I recognize I may be flaunting best practices at times.
My question is specifically related to best practices (or just common sense) when using rm inside a shell script. My googles have only turn... |
This is my first Java program, where I have a class that gets XML data from a certain website and another class that does all the database related tricks. I omitted all non-related code to this case.
So the idea is simply to get the field names in the database table, then use the retrieved XML's content to fill an arra... |
I implemented a basic Matrix class for additions of matrices, multiplication of them, and multiplying every entry of matrix by constant, operator== and operator!=, overloads for I/O operations using istream and ostream.
Before you start reading it, please look at some rationale about horrible aspects of it:
The reason... |
I feel like this code is pretty sloppy and can be accomplished in a foreach loop. But it's a bit complex using a multi-dimensional array.
Can this be cleaner? You can see I'm repeating much of the same code in each li, minus some class and array key differences, etc. Should this be a foreach loop? What's the best appro... |
Below is a function that determines if Class B uses Class A.
Currently, it tests for:
Fields
Superclass
Constructors
Methods
private boolean uses(Class<?> b, Class<?> a){
// Test for Declared field
for(Field f:b.getDeclaredFields()){
if(f.getGenericType().equals(a))
return true;
}
... |
I needed the ability to do a few extra things with a WebBrowser control on a .NET Windows Forms Form, and I found it needed some updates.
So, I made a few. I added some JavaScript manipulation, and a configuration class so that it can be tweaked a lot. I wanted to be able to add and execute arbitrary JavaScript, as wel... |
The code below works. The timings are as close as I can get to the system not packing out.
Basically telnet to a server to play tic-tac-toe. Automated it. Bottom left is 1, middle left is 2, middle right is 3 etc
Once a game is finished, I say "yes" and go again.
Anyway I can optimise it?
#!/usr/bin/env python
from tel... |
So I've just started learning about MySQL and PHP to create a fantasy league tracker for Game of Thrones for my office. I got it to technically work fine, but I think it's way clunkier than it has to be, with a lot of repeated code, and I'd like to know how to clean it up and streamline things.
I'd also ideally like t... |
I was inspired from question here, to implement function container that holder any kind of function by using boost::any, I have carried on and extend it further to make the functions holder accept lambda and functor. Also, I have implemented my own any class (AnyFunction) which is seemed work perfectly.
I would like to... |
The following method copies data from Informix db to SQL Server db and it's so slow, I want to refactor it so it could be more readable and faster:
public static int copyEmpData(DataTable employeeDT, DateTime from_date, DateTime to_date, string con)
{
string db_con = con;
if (con != "1")
con = "1";
... |
I saw a game made in Python and PyGame in a tutorial, so I thought I'd make a game like it in Allegro5 and C++. I think I made my style a little better than my style before since I stopped putting everything in the main function, and I also stopped using 'magic numbers'. I'd like to know of your opinions, and what else... |
A binary tree is balanced if both its children are balanced and the difference between the heights of its children is at most 1.
/**
* Definition for a binary tree node.
*/
class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode parent;
TreeNode(int x) {
val = x;
}
}
public... |
I wrote a small program for fun to try to prove Pi by taking a certain precision and radius and using it to calculate the area of the circle. My method should be giving me an area that is just slightly larger than the actual area of the circle, approaching the actual area as the precision gets smaller.
The funny thing... |
This checks if both the left and right subtrees are binary search trees. If they are, then it compares the nodes data with the maximum element in the nodes' left subtree and minimum element in the nodes' right sub tree.
class Node{
int data;
Node left;
Node right;
Node(int x){
data = x;
}
}
... |
I've designed my new website:
Now I want to build up my HTML as semantic as possible.
Here's my first attempt / set-up:
<html>
<head>
...
</head>
<body>
<nav id="menu" role="navigation">
<ul>
<li>Home</li>
<li>Het park</li>
<li>...... |
I am working on a React-Redux app, which is a CRUD application for a school. The first part was to implement adding/removal of classes (aliased to standard). However, the code seems unreasonably bulky to me, even when I just started out.
I have split some of the code across various components, but my main container sti... |
So the idea is to maintain a cache of shared Observables - accessible by a key - which if not present will produce one using the given factory.
The underlying shared Observable is accessed via an Observable created on each invocation of get - this is in order to be able to maintain ownership of the shared Observable an... |
I have C++ code which written for mex in MATLAB. It used to compute the total different between a pixel and its neighborhood (8 neighborhood in my code). The code ran and gave me an expected result. However, I think that we can make my code more faster (because of a lot of if statement). I am very happy if someone can ... |
I am learning Java and hence practicing it from here. The solution seems pretty trivial to me but still I would like to have a honest review which would guide me to following ideas:
Am I maintaining class Invariants?
Do I need to have more Domain specific error messages?
Although the solution seems trivial but I am mi... |
I've just made this program and I want to know how to improve it. It just receives a word and prints it backwards. Sequences of numbers are also accepted, but not white spaces (that's why I used scanf).
#include <stdio.h>
#include <string.h>
int main(void)
{
const unsigned short MAX = 30;
char array[MAX];
... |
I coded this solution for this problem:
Given a string, eliminate all “b” and “ac” in the string, you have to replace them in-place, and you are only allowed to iterate over the string once
Seems to work but I am not sure if I violated the "you are only allowed to iterate over the string once" requirement. Did I?
Other... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.