Skip to main content

All Questions

Filter by
Sorted by
Tagged with
3 votes
1 answer
264 views

Spoj-Prime Generator

Question- Generate all prime numbers between two given numbers. https://www.spoj.com/problems/PRIME1/ My attempt- I used segmented sieve method. ...
suyashsingh234's user avatar
3 votes
0 answers
369 views

Python2.7 Some xor fun

After doing the Cryptopals challanges, which I found scrolling through codereview, and finally being able to solve set1 challenge 6. I decided to have a little xor fun, and make an automated xor ...
Ludisposed's user avatar
  • 11.6k
2 votes
1 answer
2k views

Leetcode 3Sum problem using hashmap in Python

For practice, I solved Leetcode 15. 3Sum question: Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives ...
sln's user avatar
  • 61
2 votes
4 answers
636 views

Project Euler #2 - Even Fibonacci numbers

Given: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By ...
CodeYogi's user avatar
  • 5,127
2 votes
1 answer
407 views

Leetcode atoi (string to integer)

link here I'll include a solution in Python and C++ and you can review one. I'm mostly interested in reviewing the C++ code which is a thing I recently started learning; those who don't know C++ can ...
watch-this's user avatar
2 votes
5 answers
122 views

Revised: Counting subnumbers divisible by a given prime

Assume we are given a number and a prime p. The goal is to count all subnumbers of number ...
Mohammad Ali Nematollahi's user avatar
2 votes
1 answer
1k views

TDD: String Calculator Kata

String Calculator Create a simple String calculator with a method int Add(string numbers). The method can take 0, 1 or 2 numbers, and will return ...
Caridorc's user avatar
  • 27.6k
2 votes
1 answer
97 views

Optimize Performance challenge 'Vinay Queried '

Input: The first line contains N denoting the length of Target String. This line is followed by the Target String. The Target String is followed by an integer Q denoting the number of queries ...
sandesh indavara's user avatar
2 votes
3 answers
2k views

Determine Collatz sequence length for given starting values

I am trying to get into the habit of solving programming puzzles in my spare time but am stuck on the first one (which I know can be for a large number of reasons, hence my posting for help). Shown ...
Teererai Marange's user avatar
2 votes
1 answer
987 views

How to apply Python generators to finding min and max values?

I'm solving yet another problem in HackerRank (https://www.hackerrank.com/challenges/determining-dna-health/problem). In short: you are given 2 arrays (genes and <...
Denis Shvetsov's user avatar
2 votes
1 answer
297 views

Aho-Corasick algorithm to scan through a list of strings

This is a follow-up to my previous question about finding min and max values of an iterable. Aho-Corasick algorithm was suggested to solve the problem. Below is my solution with the use of ahocorapy ...
Denis Shvetsov's user avatar
2 votes
1 answer
401 views

MaxCounters Codility Challenge

I've been doing some Codility challenges lately and the MaxCounters challenge got me stumped: You are given N counters, initially set to 0, and you have two possible operations on them: ...
CEH's user avatar
  • 31
2 votes
1 answer
1k views

Project Euler # 36 Double-base palindromes in Python

The decimal number, 585 = 1001001001 (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. (Please note that the ...
user avatar
2 votes
1 answer
2k views

My take on the algorithmic crush problem from HackerRank

This is my solution to the Algorithmic Crush problem from HackerRank. Can I get any comments regarding where I can improve the code to be more efficient? You are given a list of size \$N\$, ...
Akan's user avatar
  • 315
2 votes
2 answers
473 views

Project Euler # 52 Permuted multiples in Python

It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, ...
user avatar
1 vote
1 answer
575 views

Coin Flip Streaks script

I am attempting to complete the coin flip streaks problem from automate the boring stuff with python. My code works fine but my only concern is the phrasing of the task. Does the question want us to ...
JerryTn's user avatar
  • 19
1 vote
1 answer
275 views

Leetcode group anagrams

Link here I'll include a solution in Python and C++ and you can review one. I'm mostly interested in reviewing the C++ code which is a thing I recently started learning; those who don't know C++ can ...
watch-this's user avatar
1 vote
0 answers
469 views

PyQt6 program that lets you adjust the HSV values of an RGB color

I don't know how to actually describe what this script does concisely. I am writing GUI programs using PyQt6, and I want the most beautiful palette for my programs, so I browsed Wikipedia for a bunch ...
Ξένη Γήινος's user avatar
0 votes
1 answer
380 views

Python program to find the substring with concatenation of all words

This is a Leetcode problem: You are given a string, S, and a list of words, L that are all of the same lengths. Find all starting indices of substring(s) in S that is a concatenation of each word ...
Justin's user avatar
  • 2,485
0 votes
1 answer
213 views

Leetcode longest valid parentheses

Link here I'll include a solution in Python and C++ and you can review one. I'm mostly interested in reviewing the C++ code which is a thing I recently started learning; those who don't know C++ can ...
watch-this's user avatar
0 votes
1 answer
185 views

Counting subnumbers divisible by a given prime

Assume we are given a number and a prime p. The goal is to count all subnumbers of number ...
Mohammad Ali Nematollahi's user avatar
0 votes
2 answers
544 views

Project Euler # 43 Sub-string divisibility in Python

The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. Let \$d_1\...
user avatar
-2 votes
1 answer
1k views

Project Euler # 50 Consecutive prime sum in Python

The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum ...
user avatar

1 2
3