Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 227157

Use this tag when the code is a solution to a programming challenge. Always include a sufficient description of the problem to be solved - while a link to the challenge is welcome, the review request needs to be complete when the challenge site is unavailable.

1 vote
1 answer
265 views

Advent of Code 2020 Day 9 in Python

This is a solution for part 1 & 2 of Advent of Code 2020 Day 9. Given the example input sample.txt: 35 20 15 25 47 40 62 55 65 95 102 117 150 182 127 219 299 277 309 576 Part 1: find the first number …
Marc's user avatar
  • 5,664
4 votes

Project Euler #645 -- speed up Monte-Carlo simulation in Python

Welcome to Code Review. Nice implementation, easy to read and understand. Optimization There are some "expensive" operations that can be simplified. Below I commented the relevant parts: def Exp(D): …
Marc's user avatar
  • 5,664
5 votes

Java generics with wildcard vs non generic List to deal with non generic data

@TorbenPutkonen already provided a great review, I just wanted to add something about usability. Depending on your use case, returning a List<Object> means that you need to do the casting later. For e …
Marc's user avatar
  • 5,664
3 votes
Accepted

Leetcode minimum path sum

Python Naming: self.x_size and self.y_size can be shorten to self.m and self.n, following from the problem description. Initialization: x1, y1 = start_point self.matrix = matrix[x1:][y1:] I think th …
Marc's user avatar
  • 5,664
11 votes
Accepted

Leetcode two sum

I am not an expert in C++ but I can give a feedback about the Python solution. Your current solution runs in \$O(n^2)\$. Basically, for each number n of the input nums, find target - n in nums. How to …
Marc's user avatar
  • 5,664
3 votes

Program Arcade Games: Ch 16 Worksheet 2D-Array Algorithm

Welcome to Code Review, few suggestions: Instead of calling .format() you can use f-Strings: print(f"#{i} is the one.") Is better to return the result, instead of printing in the method and break You …
Marc's user avatar
  • 5,664
1 vote
Accepted

Molybdenum2019 challenge efficient implementation

Nice solution, find below my suggestions. Creating a list from a set: List<Integer> listaLideresOrdenada = new ArrayList<Integer>(); listaLideresOrdenada.addAll(listaLideres); The set can be passed …
Marc's user avatar
  • 5,664
2 votes

Beginner - OOP Project - Airline reservation system

Nice implementation, it's easy to understand and well structured. Few suggestions: Seat class class Seat: def __init__(self): pass class FirstClass(Seat): def __init__(self): …
Marc's user avatar
  • 5,664
6 votes

Array manipulation: add a value to each of the array elements between two given indices

Nice implementation, it's already very efficient. Few suggestions: Expand the variables in the for-loop from for q in queries to for a, b, k in queries. Given the problem description it's easier to r …
Marc's user avatar
  • 5,664
30 votes
Accepted

Printing 1,000,000 numbers in 1 sec. in Python

Nice solution, few suggestions: Printing the numbers one by one might be the issue. Generate the list of numbers first and then call print only once. The case n==1 is already handled, so the first el …
Marc's user avatar
  • 5,664
2 votes
Accepted

HackerRank - Climbing the Leaderboard: I don't understand why my code is exceeding the time ...

Removing duplicates efficiently ranked=[i for n, i in enumerate(ranked) if i not in ranked[:n]] This line creates a copy of ranked at each iteration, which makes it inefficient. Since ranked is alrea …
Marc's user avatar
  • 5,664
3 votes
Accepted

LeetCode 839: Similar String Groups II

Nice approach and implementation. I like how you broke down the solution into simpler methods. Few suggestions: Naming The name of the method depthFirstSearch is not the best. From a method with such …
Marc's user avatar
  • 5,664
2 votes
Accepted

LeetCode 8: String to Integer (atoi)

Nice solution, it's compact and simple to understand. There is little to improve, few suggestions: Imports: there are a lot of imports, maybe leftovers of previous attempts. Try Except block: should …
Marc's user avatar
  • 5,664