instruction
stringlengths
71
95.1k
I'm posting my C++ code for LeetCode's Snapshot Array. If you have time and would like to review, please do so. Thank you! Problem Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals ...
Here is my solution: I want to know if my solution fits the requirement 100%? Or if there is any better solution? Constraint of the question: must be singly linkedlist must use recursion, and no helper methods allowed. The method must return the head node of the merged list. class Solution{ Node dummy=new Node(0...
I incorporated the substantial changes suggested in my previous question that involved building a web-scraper for gathering tennis data. The improved code is shown below: Scraper class: package scraper; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Ele...
I'm creating a GOLang Linux distribution installer. The architecture is straight forward. I have N parameters and uses them in N installation steps. Summarizing: Every step implements a interface with the Run method. For each step S, do S.Run(parameters), if failed, handle the error. The complete source code is here:...
I want to familiarize myself with more data structures. As such I implemented a Node, singly-linked-list, as well as an algorithm to sum the digits of two such lists where each node contains the digits of a number. The order of the digits can either be largest digits first or smallest. Taking the number 1,234 as an exa...
I'm posting my C++ code for LeetCode's Longest Duplicate Substring. If you have time and would like to review, please do so. Thank you! Problem Given a string S, consider all duplicated substrings: (contiguous) substrings of S that occur 2 or more times. (The occurrences may overlap.) Return any duplicated substrin...
Recently, I've been trying to get back into Haskell, so I tried coding up a LZSS implementation. I realize this is much more easily implemented imperatively, but I wanted to challenge myself. The last time I tried doing this was back in my Functional Programming class and it went poorly. It worked, but the compression ...
How could I reduce this schedule checker? There are too many conditions. This code is supposed to make sure we're not booking events for employees that are already booked in a specified timeframe. for i in range(len(employeesChosen)): info = get_employee_info(employeesChosen[i]) event_done = False if employ...
I have a use case where I need to run multiple tasks in series. Each task is required to perform some database operations. In my code step_1, step_2 and step_3 are these task which get executed in series (Async Waterfall) Following is my code const config = require('config.json'); var mysql = require('mysql'); var asyn...
I need to add search filters for firebase So that I can get search result easily and precisely I was altering the code from hereThis Medium Post I would like to optimize this code. void main() { print(setSearchParam("Dr apj abdul Kalam")); } setSearchParam(String caseNumber) { List<String> caseSearchList = List();...
I'm using GraphQL and go-pg. I have many entities like these: type Player struct { ID int CreatedAt time.Time `pg:"default:now(),notnull"` TeamID int `pg:",notnull"` Team *Team Type int Score int64 `pg:",notnull"` Note *string // and others... } type PlayerInput...
I'm trying to create a dependent dynamic dropdown in jQuery, in which the number of dropdowns is not fixed. Let's say we've four provinces, each has cities, and each city has sections. Each section may or may not have a sub-section, and the list continues to ten or more dropdowns. I wrote a sample code and it works, bu...
This code works, and solves the problem, but doesn't satisfy some time requirements, especially when the 'nums' array can have a length of over 1000. How can this be optimized? Just reference: This function does x number of operations on any element in the nums array so that the sum of all elements in the final array i...
I am trying to restructure a function more clearly and readable that has multiple return statements. Usecase Get a token: if the token does not exist in the database then generate a new one and return it. if the token exists -check if expired, if expired update it with a new one, -if not expired then return the sam...
My answer to Project Euler problem 4 (largest palindrome of product of two 3-digit numbers) is below. Please suggest improvements, style changes, indentation, commenting, naming, ... And nitpicks are welcome! Other than general stuff about the code below, I'd like to ask specifically about assert is good to use? Frown...
What I am trying to do, is to get weather data, data about bike trips and populate the postgresql database in order to be able to work with this data from Power BI/Tableau/any other tool. I have two different data sources. The first of them is yr.no API, which I am using to access weather data. The second one is osloby...
I have this code that fetches data from a 3rd party api and sends it to my backend to be processed. The 3rd party api needs to target the user's localhost address so it has to come from the front end. I have the code below which works perfectly fine but it looks messy, I'm sure there is a better way to write it. Any su...
Ok so my name is qqqiiiiiiiifdff and I made this code that simulates a perceptual color picker algorithm that selects the nearest color by iterating over the color array and selecting the minimum error, processing the calculations in a perceptual manner. This is an example: #include <stdint.h> #include <math.h> inline...
I recently had cause to write some code which would take an object like const obj = { a: 1, c: { d: 1, e: 1 } }; Which we regard as a rooted labelled tree, I then want the rooted labelled subtrees, e.g. in this example { c: { e: 1, d: 1 }, a: 1 } { c: { e: 1, d: 1 } } { c: { e...
Summary I have been playing with Rust for a couple of days, so I thought I would implement something rather simple. This code generates a random variation of board for well-known game of Battleship. In this variation, there are one 4-cell ship, two 3-cell ships, three 2-cell ships and four 1-cell ships. There's definit...
Beginner level script for a countdown timer. Would appreciate if you could point the things I could do to be more efficient. Basically, I would want to check if the current day is either a "workday"(Mon - Wed) or a "freeday"(Thur-Sun) and achieve the following: If it's a workday, and the current hour is a working hour...
I am new to Python and I am using Python 3.8 and Selenium. This is a follow up of my previous question. Since I received several useful suggestions I have re-written the following code. The code works fine and is much better than previous version. But I wonder if I can convert my code to be Page Object based. Will this...
The following data structure is meant for manipulating algebraic/mathematical sets. I want Set<T> to be compatible and interchangeable with any similar data structure available in .NET. I didn't use HashSet<T> because I don't like the fact that HashSet<T> is unordered. Kindly review it for design and efficiency. What i...
In my project, so this controller is working perfectly, my objective is to read the log file from the server which is created on daily basis, so I have to read the log file which is heavier in size around maybe 2GB, so my question is that please review the below code and advise my is my code is smart enough to read suc...
This program displays a list of TV characters. You can kill them off by random or bring them back by name. I have used the random.choice function. I've defined a couple of functions so that the while loop looks a little more clean. In two of the functions, bring_back and check_decision, we assign True to invalid_input ...
I am working on a utility to manage shared content libraries for Work from Home scenarios. Basically I have libraries of thousands of Autodesk Revit family files, and I want to host those files on AWS S3, and then manage a local copy of the library based on what is hosted on S3. To that end I have developed an XML "ind...
I have designed a logger class to log messages to a file. It uses an independent thread to log the messages save to a queue previously using the main thread. I want to receive reviews about it. #include <iostream> #include <queue> #include <mutex> #include <condition_variable> #include <fstream> #include <atomic> #incl...
It's an assignment from the Odin Project. Here's my implementation: #!/usr/bin/env ruby def caesar_cipher(str, shift) low_alpha = ("a".."z").to_a high_alpha = ("A".."Z").to_a length_alpha = low_alpha.length chars = str.split("") ciphered = "" chars.each do |char| if low_alpha.inclu...
The array "scores" tells the total points for each person involved in a contest. So for example: User A: 100 points User B: 90 points User C: 90 points User D: 80 points User E: 75 points User F: 60 points According to above scores we also have this ranking: User A: #1 User B: #2 User C: #2 User D: #3 User E: #4 Use...
Inheritance Challenge 2 - Employees, Bosses and Trainees Create a main class with a Main Method, then a base class Employee with the properties Name, FirstName, Salary and the methods Work() and Pause(). Create a deriving class boss with the propertie CompanyCar and the method Lead(). Create another deriving class...
So I have a 12 x 6 2D numpy array for input which consists of 7 possible board objects (characters from 'abcdefg'). From a 2D numpy array I wish to generate all the possible unique 2D arrays, in whose parent array 2 adjacent elements in each row have been swapped. In the worst case this means 60 (5*12) swaps for each p...
I've been writing a little task manager in C++ in my spare time. It's also the first time I am posting here for a review, I hope someone can spot any mistakes. There's still a lot to implement and optimise, but the idea is for this to be a task manager that optionally uses any platform-dependent threading API (otherwis...
I'm posting my C++ code for LeetCode's LRU Cache. If you have time and would like to review, please do so. Thank you! Problem Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be positive) of the k...
I am looking for a way to speed up my basic IP scanner/port scanner in Python 3.8. My IP portion works, the port scan work, I just want to speed it up, in a format that someone learning python would understand. #testing scanner.py import socket import subprocess import sys from datetime import datetime def scan(): ...
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Problem Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be positive) of the key if the key exists in the cache, ...
I'm posting my Java code for LeetCode's LRU Cache. If you have time and would like to review, please do so. Thank you! Problem Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be positive) of the ...
I'm looking for a code review and code improvement for my own small server. The server accepts the requests: User Join,User Leave,User Text Notify Group Join, Group Leave, Group Notify Request Time. The syntax for User Join/Left Group Join/Left: ** DSLP-3.0 User Join NameOfUser DSLP-Body ** The syntax for Group Notify...
This is an interview question to generate the below pattern of numbers in a sequence, which is: 12.34, 23.45, 45.67, 78.910, 1112.1314, 1617.1819, 2223.2425, 2930.3132, 3738.3940, 4647.4849, 5657.5859, 6768.6970, 7980.8182, 9293.9495, 106107.108109, 121122.123124 We can use starting seed number as 12 and have to genera...
I am implementing a binary search algorithm and my code is as shown bellow: def binary_search(a, x): left, right = 0, len(a) ...
it's the second object oriented program i've worked on, more details on https://hyperskill.org/projects/96?goal=391. I've added as much documentation as needed, as a first time, to explain each component. class Matrix: def __init__(self, dimension, elements=None): """ Use: Matrix([num_o...
I have made a script that syncs one folder to another. So if, for example, you saved some changes in a file in directory A, then that file would have the same contents om directory B if you set it up. It runs on Python 3 and the watchdog module. If you are wishing to try it out (and please do), make sure to install wat...
I am developing a statistics library in .net. I have developed a Set<T> data structure. Now, I want to derive a data structure named DescriptiveStatisticalSet<T>, and I want this set to be able to operate only on integer and double types. Problem: I want to implement a generic type that is able to work with integer an...
I have a form on my page. I am using jQuery validation for client-side and PHP for server-side validation. I am using PDO. I don't have any issues with client-side and server-side validation. My form is working. I want to know that is this code is the best code with serverside validation with logic? Client-side validat...
I create https://github.com/storenth/react-redux-todo and ask to review my Todo-react-app for programming pattern: dividing components into presentational components and container components. Here’s the basic idea behind it: if a component has to have state, make calculations based on props, or manage any other complex...
This Q&A was iteration 1. Now there is Iter 2: Reusable, robust c++ std::hash<mpz_class> for GMP's big integer type 1. Goal My intention is to provide a fast hashing algorithm to hash GMP's big integer type mpz_class and mpz_t so I can use these types as keys for an unordered_map. The code shall be reusable for others...
As you can see these functions differ only in keys []int and keys []*int (and in name). func (db *myDB) QueryWithKeys(keys []int) ([]*models.Player) { var players = make([]*models.Player, len(keys)) _ := db.Model(&players).Where("id in (?)", pg.In(keys)).Select() // several other equal code here return play...
The problem was using single Stream from the HTTP response in multiple consumers simultaneously. For example: while data is loading, I want write it to the some cache file and deserealize it at the same time. This code will not work for an obvious reason. But it represents some desired things. private readonly HttpClie...
I have the following class: public class UpdateData { public static boolean updateHasMessage(Update update) { return update.hasMessage() && update.getMessage().hasText(); } public static boolean updateHasCallbackQuery(Update update) { return update.hasCallbackQuery() && (update.getCallback...
As a beginner coder in js, I'd like to hear about further improvements of the following code, but nothing too advanced, please. The program is meant to work the following way: A user inputs a color array like this one: ["blue", "green"] The code checks if those words are valid inputs (they should be found in a referen...
I have implementing a simple version of Dijkstra's algorithm in C#. Could this be made more efficient? Does it need to be modified? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace dijkstra { class Program { static void Main(string[] arg...
The challenge can be found here. In short we have a recursive function, and we need to find when \$z_i\$ is equal to one. $$ \begin{align} z_1 &= 1\\ z_i &= z_{i-1} * a\ \%\ n\\ \text{find}\ z_i &= 1 \end{align} $$ Input range: $$ 2 \le a \lt n \le 10^9 $$ I have written the following. It is simple, but too...
I am using below code to rename and delete video. Need review for the following: Code optimization Performance Overall code review renameVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int index = filePath.lastIndexOf('.'); ...
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume al...
I'm posting my C++ code for LeetCode's Guess Number Higher or Lower II. If you have time and would like to review, please do so. Problem We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I'll tell you whether the n...
I'm running MicroPython on an ESP32 relaying sensor data to my MQTT server for Home Assistant. I only want it to emit a message when state has changed and a motion detected state to hold for a minute before returning to a clear state. I see a lot of examples using sleep, but I don't like the blocking nature of sleep as...
How can I simplify this functioning JQuery validation process: class UserEdit { addUser(uobj) { if(uobj.adduser == "" && uobj.addfullname == "" && uobj.addemail == "" && uobj.addlevel == "") { $('#adduserError').show(); $('#addfullnameError').show(); $('#addemailError').show(); ...
I'm posting my C++ code for LeetCode's 1320. If you have time and would like to review, please do so. Thank you! Problem You have a keyboard layout as shown above in the XY plane, where each English uppercase letter is located at some coordinate, for example, the letter \$A\$ is located at coordinate \$(0,0)\$, the ...
I'm trying to create a component that receives an array, this component is going to show a list with props data const Mesas = [{ id: 1, valor: 500, produtos:['COCA COLA', 'FANTA'] },{ id: 2, valor: 100, produtos:['PRATO1', 'PRATO2'] }] const App = () => { return (<ListaMe...
The code below iterates through the nodes of an XML file and updates values based on a Regex expression in the rule child node from an XPath expression. XML is included at the bottom. Are there better alternatives to this approach? Would using LINQ be a good approach? using System; using System.Text.RegularExpressions;...
I'm posting my Python code for LeetCode's 1320. If you have time and would like to review, please do so. Problem You have a keyboard layout as shown above in the XY plane, where each English uppercase letter is located at some coordinate, for example, the letter \$A\$ is located at coordinate \$(0,0)\$, the letter \...
I am a Math tutor and I found the site https://www.yksityisopetus.fi/ where one can search pupils. I made a Python parser to find pupils that want Math teaching with at least 25 €/hour. Are there any improvements for this code? import requests import tkinter as tk link = "https://www.yksityisopetus.fi/opiskelijat/mate...
Looking for any feedback to improve practices on the following logic, and I have removed large chunks of documentation to reduce noise. I feel the areas that could expect heavy criticism are the win/tie condition checking. Main.cpp #include "Board.h" int main() { //initialize board Board gameboard; for (i...
I was playing around with sorting methods, brushing up on my algorithms. I have made the following implementation of quicksort: def quicksort(l): def inner_qs(list_, start, end): if end - start > 1: piv = list_[end - 1] aux_index = start for i in range(start, end): ...
This code unzips the downloaded subtitle files and maps them to their corresponding video file. Currently, after pairing video files with their corresponding subtitle files, it links them by renaming the subtitle file to the same file name as that of its corresponding video file. #!/usr/bin/env python3 import os, os.pa...
I need to identify the different markdown files I have so I can create a unique url structure for them. I can already identify "notes" files, and want to create a second type called "projects". My gatsby-node.js file looks like this right now const path = require('path'); const { createFilePath } = require('gatsby-sour...
Submitting for expert review. I am trying to create a Chart - Crosshair cursor in excel chart sheet. Chart - Crosshair cursor lines are two lines (one horizontal and other vertical) moving along with the cursor/pointer/mousemove on the chart. Most of the stock market online charts have such interactive tool. I have ref...
I need to extract all member accesses to expression parameter (and make sure, that they are not nested). For instance, for expression: a => a.A + a.B I need to receive list {"A", "B"}. For expression a => a.B.C exception should be thrown, as we have nested member access. I wrote the following class, but I'm not too sat...
I have a dataframe like so: id variable value 1 x 5 1 y 5 2 x 7 2 y 7 Now for every row, I want to add a calculated row. This is what I am doing as of now: a = 2 b = 5 c = 1 d = 3 df2 = pd.DataFrame(columns = ["id", "variable", "value"]) for index, row in df.iterrows(...
I have a large image and I am extracting and processing tiles in batches of a given size. A tile is normally a 256x256 region and batches are normally a power of 2. In the below example the number of tiles per cols is 3 and the number of tiles per rows is 5, and I want batches of 3. Legend: Yellow rectangle = tile, Re...
I'm not sure if I'm even approaching this correctly (still very much learning), but this is what I'm attempting to accomplish: My script gets an array from a column (tab names of the sheet) and then calls another function to copy those tabs (this part works fine). What I'm attempting to add is a separate list of prope...
I have a query that outputs a list of products with some fields from other tables. That query works fine. Now, I'm attempting to retrieve the available stock for each product in that list. I'm not sure if I'm doing it correctly or in the most performant way. Here's what I've got working so far. select distinct p.id, ...
Update: This is an older version of the question/script. The new version can be found here: Part 2: Send HTTP request for each row in Excel table I have an Excel spreadsheet where users can batch-enter records and load them into an external system (via HTTP). This is what the VBA in the spreadsheet does: A custom fu...
Our testing suite is configured using a type of hierarchical config file similar to .ini or .toml files. Each 'block' is a test that is run on our cluster. I'm working on adding unique ids to each test that will help map results to tests over time. A small example of a config file would be: [Tests] [test1] type =...
I needed a tool to monitor VM's running on my server in relatively real-time (similar to top or the many variants out there). The main things I need to keep track of are: All VM's listed via virsh list --all; Id Name State ---------------------------------------------------- 13 Experi...
I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109...
This is a beginner's class. I just need help verifying if this code is correct, or edit the parts that need fixing. n = int(input("Enter a number")) sum = 0 for i in range(1,n+1): sum = sum + i print("The sum is:", sum)
This is an implementation of a 2D peak finder from MIT's Intro to Algos. I'm a C beginner and I would really like some feedback on coding style, documentation and any other general C bad practices. Additionally have I correctly freed the memory of the recursive calls? #include <stdio.h> #include <stdlib.h> typedef str...
I am studying and practicing Python; this is my Rock-Paper-Scissors game I've built from scratch. I saw this task is for beginners. When writing this in all the examples I saw dozens of lines of code with if elif else statements. I decided to write the shortest program for this game. I'm just looking for any comments, ...
I'm new to sh and I would like to get feedback on how I can improve my code. The purpose is simple; I want to open the Jenkins JOB related to a service based on its possible aliases. If I map a service with its aliases, READ_JOB="rj readjob read-job", I want to open it by calling the script opendeploy readjob or opende...
I solved this problem statement on dear old codeforces. The Problem Statement wants users to replace occurrences of '10' in the given string with either '1' or '0' until there is no occurrence of '10' left and the string formed is the lexicographically smallest string from the set of all valid answers. This is my solut...
I created an algorithm to create lists of anagrams The input is ["eat", "tea", "tan", "ate", "nat", "bat"] Then, the output should be: [["eat","tea","ate"],["tan","nat"],["bat"]] Each array is words that are anagram. My solution is: function group(input) { let result = []; if(input.length === 0){ return...
I have small question. I don't know much about JavaScript (jQuery) or AJAX and I don't know whether I'm doing it safe from XSS Attacks, SQL injection and that stuff. I think the PHP with MySQL would be written right. The code works, I have added it below. This is PHP with database call which is called by AJAX if(isse...
The task: Determine if a word or phrase is an isogram. An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. Examples of isograms: lumberjacks background downstream six-year-old The word isograms, however, is n...
In a game of Tic-TacToe given a gamestate: game_board = [ [1, 0, 1], [0, 1, 0], [0, 1, 0] ] I have written the following piece of code to display the output of the gamestate in regards to wins: game_board = [ [1, 1, 1], [0, 1, 0], [0, 1, 0] ] # Horizontals h...
I'm working on a solution to the Following problem on Hackerrank, and I seem to have found a function that works for the purpose. However, I feel as though this is a very overdesigned solution to a problem that appears, at first glance, to be simple. This is what I've come up with so far: This code takes in two arrays,...
I am creating Monopoly using react hooks. I am using cypress for testing it. The first test I have to create is to check about dice rolls. I have three tests in which I am repeating the same kind of code. How can I refactor this? //A funcction to get the rolls of dice in number function getDiceRolls() { const dices ...
This is part of my code. List all files and read them into the list files. Now I have a dictionary my_dict. The values are the parquet files. all files must have same schema. I have more than 2000 files is my folder, so files is large. For each file I firstly gunzip all of them. Next I find all the JSON files. Problem...
For game AI development, I am currently using a slight modification on the DFS "count the islands" problem (specification below) as a solution to the One Hive Rule for the game of Hive. This may not be the ideal solution so I am open to any other ideas if you note DFS is not the best approach. Thank you. Given a 2d gr...
I'm an experienced Java developer, however I don't have experience with reflection or Annotation classes. For fun, I tried to develop a CSV Reader class which can parse each row into a particular type. Here is my code: package com.richardrobinson; import java.io.BufferedReader; import java.lang.annotation.*; import ja...
I'm building a dead simple CLI app that parses a RSS feed and prints it to stdout. I needed a simple word wrapping function to, well, wrap lines to an arbitrary length (say 80 or 120 chars). I ended up using this, as it gets the job done. However, as I'm still new to Go, I was wondering if this can be improved? func wo...
It's the first time a write a non-trivial mongodb query, and I came up with one that does work, but is 123 lines long! Surely there must be a way to write it in a more concise way. The purpose of the query is to return aggregated (average) values, using groups that are determined by the $interval parameter in seconds. ...
I am currently learning Java; I could really use some help from more experienced programmers. How can I clean up my Tic-Tac-Toe code? What mistakes have I made? Can I use more exception handling? I tried to use exception handling, in isValidStepCheck and takenFieldCheck, but I don't think I used it efficiently. public ...
I have a simple class to ensure the date entered into a form is a valid date. Where can I improve it, have I missed anything? public class ValidDate : ValidationAttribute { protected override ValidationResult IsValid(object value, ValidationContext validationContext) { var dateToParse = value.ToString()...
// variables // arr has elements to be sorted var arr = [] // temp is to store the intermediate results after merging var temp = [] // seen is for marking visited i.e. sorted half as green var seen = [] // length of array var len = 50 // canvas initialisations var canvas = document.getElementById("myCanvas") canvas....
I'm a solo developer and a friend told me that my code is not very readable. I always write code trying to keep it DRY while not taking longer than it would take doing it in an "easier" way. Here is the skeleton for My Profile feature which will initially have read-only values. When the user wants to update it, it turn...
The code below works as intended but I'm not sure the way I'm passing it to a component is correct. Also, I don't think the way I wrote this function is recommended. It's not a pure function and probably should be split into two functions where one needs the output of the other. 'books' and 'authors' are 'state' object...
I am a beginner in programming with Python. I am going to start my first job in this specialization. Can I use this code for presenting my skills at an interview? import os import time import datetime import sys from PyQt5 import QtWidgets, QtGui, QtCore class MainForm(QtWidgets.QMainWindow): # atribute to save...
I had the below problem in a coding test and I got 28/30 tests passes and 2 failed due to a time-out. Problem You have created a programming language and now you have decided to add hashmap support to it. It was found that in common programming languages, it is impossible to add a number to all hashmap keys/values. So...
I'm solving a knapsack problem here. It works, but gives time limit exceeds on a certain test case. Problem statement There are N items, numbered 1,2,…,N. For each i (1≤i≤N), Item i has a weight of wi and a value of vi Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of th...
I have written a few classical Python functions in JavaScript. I would appreciate any kind of feedback. The main goal is to learn about JavaScript. For example errors, improvements or existing JavaScript functions that I missed. Additionally, challenges that would be interesting to tackle next would be appreciated. // ...