Skip to main content

All Questions

Filter by
Sorted by
Tagged with
-2 votes
1 answer
259 views

HackerRank frequency queries

need some help or advice, HackerRank's frequency-queries challenge, the challenge of this Hackerrank problem is to check if the frequencies of number in your data structure matches the queries. small ...
NaturalDemon's user avatar
2 votes
1 answer
481 views

Project Euler Problem #755

As the title indicates this is one of the last most problems of Project Euler. The problem is straightforward. However, similar to the rest of the Euler Project problems either ...
Lady Be Good's user avatar
3 votes
1 answer
1k views

PowerShell script binary-decimal-hexadecimal-ipv4 convertor

This is a fully functional PowerShell script I wrote not long ago that converts data (numerical data) among 4 data formats: binary, decimal, hexadecimal and ipv4. It supports 12 conversions, it can ...
Ξένη Γήινος's user avatar
2 votes
1 answer
70 views

Molybdenum2019 challenge efficient implementation

I'm working on a solution that is correct but inefficient. https://app.codility.com/programmers/task/leader_slice_inc/ This is my code : ...
Antonio Diaz's user avatar
2 votes
1 answer
423 views

Find sub-list index with the closest to a given number sum

The task that I have to perform is to take an array of a specific length, and figure out which sub-list has the closest sum to another given number. Then, I need to print the index of that sub-array. ...
geoka's user avatar
  • 31
2 votes
1 answer
229 views

Counting binary substrings

The exercise i am working on requires me to read a binary sequence stored in a text file. The objective is to find the occurrences of all subsequences of length between a and b (their values are given ...
alex108's user avatar
  • 129
1 vote
1 answer
90 views

return the number of times is state of bulb changed?

Today in an exam I faced a problem which is Toggled Switches(Hacker Earth) as it is an exam question So, I am unable to send the question or its link (exactly). Problem: we have to print a number ...
chandu_reddim's user avatar
1 vote
1 answer
273 views

MSD Radix sort in Place in c++, Object/Pointer Oriented

Memory:O(log(max)base(mod)*mod)Speed:O(log(max)base(mod)*n) I did a radix sort in place to not get a auxliar array. In the process i discorver a few things. Is imposible to do LSD radix sort in place ...
bigotes0invisibles's user avatar
2 votes
2 answers
167 views

Finding minimum steps required to traverse from source to terminal

Hello everyone this is my first post here so please do critique my post if there's anything. I have made a program intended to pass a programming challenge on open.kattis.com, here. It should do as ...
ma22om's user avatar
  • 23
1 vote
2 answers
522 views

Checking the type and validity of a credit card with Luhn's algorithm in C (CS50)

I'm taking CS50 Intro to CS. In this assignment, we're asked to make a program that can identify what type of credit card (AMEX, Visa, MasterCard) is given in the input (and whether it is valid.) ...
xdxt's user avatar
  • 65
5 votes
3 answers
1k views

Printing pyramids in C (CS50)

I'm taking the CS50 course, and we're asked to create a program which takes an input (the total height of the pyramid) and outputs a pyramid of that height. i.e Here’s how the program might work if ...
xdxt's user avatar
  • 65
1 vote
1 answer
1k views

Follow-up: How can we optimizing Java BigInteger operations?

This is the follow up question of How can we optimizing Java BigInteger operations? Problem Reduce the number to 1 in a minimal number of steps, following the rules: ...
Anit Shrestha's user avatar
4 votes
2 answers
270 views

Minimum number of copies of an application a company needs to purchase

Some applications from vendors are allowed to be installed on multiple computers per user with specific restrictions. In our scenario, each copy of the application (ID 374) allows the user to install ...
bit's user avatar
  • 143
26 votes
2 answers
6k views

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

Here's a fairly simple task from CSES Problem Set - Permutations 1070 that reads: A permutation of integers 1,2, …, n is called beautiful if there are no adjacent elements whose difference is 1. ...
Bor's user avatar
  • 507
3 votes
1 answer
129 views

palindrome code in C times out in program challenge?

Hello I am making a code in C to find the value of the last sequence of palindromes of a specified size (d) and I need to optimize this code as it is for an ...
Yuri Nogueira Moreira da Silva's user avatar
2 votes
1 answer
91 views

Program to move in a 2d array given instructions, array and starting position

Original problem (not in English): https://pokval21.kattis.com/problems/pokval21.robotdammsugaren How can my code be optimized? ...
isetnt's user avatar
  • 31
3 votes
2 answers
264 views

LeetCode 665: Non-decreasing Array (C)

I'm posting a solution for LeetCode's "Non-decreasing Array". If you'd like to review, please do. Thank you! Problem Given an array nums with ...
Emma's user avatar
  • 3,542
2 votes
1 answer
2k views

DateTime range splitting algorithm

I have the algorithm which splits DateTime range into multiple ranges based on night time range. For example: Night start: 22:00, Night end: 06:00 Start time: 2020-10-26 21:00:00 End time: 2020-10-27 ...
Konrad's user avatar
  • 227
9 votes
3 answers
2k views

LeetCode 1108: Defanging an IP Address

I'm posting two solutions for LeetCode's "Defanging an IP Address". If you'd like to review, please do. Thank you! Problem Given a valid (IPv4) IP address, return a defanged version of that ...
Emma's user avatar
  • 3,542
9 votes
3 answers
626 views

CSES standard solution for range query problem giving TLE

Problem statement is from CSES This is a standard question where we are given a list of numbers and a number of queries. For each query, you have to give the sum of numbers in the given range. My ...
YetAnotherBot's user avatar
4 votes
2 answers
2k views

3-SAT Solver Python

I've written a 3-SAT solver based on this prompt: Alice recently started to work for a hardware design company and as a part of her job, she needs to identify defects in fabricated integrated ...
n00bster's user avatar
  • 165
3 votes
2 answers
3k views

10 Kinds of People Open Kattis Problem Time Limit Exceeded C++

I am trying to solve the open kattis problem '10 kinds of people' (https://open.kattis.com/problems/10kindsofpeople) using a best-first search algorithm and c++. 10 Kinds of People The world is made ...
Filip Voss Åkerström's user avatar
3 votes
1 answer
279 views

Number of inversions on a segment

I was trying to do this question and I get TLE on one the test cases (the actual link to the question will ask you to login). What is an inversion? An inversion of an element is the number of ...
Tilak Madichetti's user avatar
7 votes
3 answers
581 views

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

I am trying to solve Q645. While the logic used for my code seems to be appropriate, the code itself is way too slow for the large number required in this question. May I ask for suggestion(s) to ...
KM Goh's user avatar
  • 71
4 votes
1 answer
157 views

Find first index of 1

Given a sorted array consisting 0’s and 1’s. The task is to find the index of first ‘1’ in the given array. I submitted the below code in geeks for geeks and the execution time is 5.77. Need help in ...
learner's user avatar
  • 85
8 votes
4 answers
476 views

Calculate sum of multiple series within array

The exercise is as follows: Player A will write list \$ a \$ consisting of \$ n \$ numbers. Player B will take a look at the paper. After that the A player will ask player B \$q\$ questions. Each ...
user229175's user avatar
6 votes
7 answers
1k views

Verifying if a string can be created with the letters of another string

This is basically based on the following question on stackoverflow which was based on a codewars assignment that can be found here Problem statement Complete the function ...
Icepickle's user avatar
  • 825
2 votes
0 answers
1k views

Better performance in solution for the Dole Out Cadbury challenge

Dole Out Cadbury Problem Description You are a teacher in reputed school. During Celebration Day you were assigned a task to distribute Cadbury such that maximum children get the chocolate. You have ...
poojitha yadavalli's user avatar
3 votes
1 answer
52 views

Box and Cox process

The code obtains Box and Cox transformed data. The original data is a Pandas DataFrame and the process uses this DataFrame. I am trying to speed up the following code. If you can elaborate in faster ...
Mario Arend's user avatar
3 votes
0 answers
197 views

Count unique subsequences

I came across this question in a coding competition (Java-restricted) and I got a time-length-exceeded. I am unable to provide a link as the contest is closed now. Can I know how can I optimise this? ...
PRANATHI G's user avatar
3 votes
1 answer
273 views

Analysis of multiple game scores

I am trying to create a list based on some data, but the code I am using is very slow when I run it on large data. So I suspect I am not using all of the Python power for this task. Is there a more ...
Mario Arend's user avatar
3 votes
3 answers
347 views

Project Euler 50: Consecutive prime sum

I just finished solving Project Euler's 50th problem, but it's awfully slow. I'd like to hear your thoughts on my code's efficiency and practices. Problem Statement The prime 41, can be written as the ...
Arber's user avatar
  • 31
2 votes
0 answers
277 views

Performance challenge: Box operations (HackerRank) (C, Python)

Recently I've been doing some challenges on HackerRank and came across this one. First, I tried with Python, and then C. Both of my codes failed due to timeout restrictions. It would be very helpful, ...
Jaafarb's user avatar
  • 21
3 votes
1 answer
276 views

LeetCode 146: LRU Cache III

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) ...
Emma's user avatar
  • 3,542
1 vote
1 answer
250 views

LeetCode 399: Evaluate Division

I'm posting my C++ code for LeetCode's Evaluate Division. If you have time and would like to review, please do so. Thank you! Problem Equations are given in the format A / B = k, where A and B are ...
Emma's user avatar
  • 3,542
1 vote
1 answer
888 views

LeetCode 809: Expressive Words

I'm posting my C++ code for LeetCode's Expressive Words. If you have time and would like to review, please do so. Thank you! Sometimes people repeat letters to represent extra feeling, such as "...
Emma's user avatar
  • 3,542
5 votes
1 answer
82 views

Finding all factors and prime factors of a number

I am working on the Project Euler, number 3 project (finding the largest prime factor of 600851475143), but I wanted to take it a step further and write something that will list all factors and prime ...
Zach Frost's user avatar
2 votes
0 answers
809 views

LeetCode 218: The Skyline Problem II

Here I'm posting my Java code for the skyline problem. If you have time and would like to review, please do so, I'd appreciate that. Problem A city's skyline is the outer contour of the silhouette ...
Emma's user avatar
  • 3,542
3 votes
1 answer
470 views

LeetCode 767: Reorganize String

Here I'm posting my code for the Reorganize String problem on LeetCode. If you have time and would like to review, please do so, I'd appreciate that. On LeetCode, we are only allowed to change the ...
Emma's user avatar
  • 3,542
-4 votes
1 answer
86 views

Time limit exceeds in this simple program [closed]

Link to problem: https://www.codechef.com/JUNE20B/problems/EVENM Iam trying to solve a simple problem challenge, but getting TLE. I had a different approach earlier, so tried this, again with no ...
drac_o's user avatar
  • 101
0 votes
1 answer
633 views

LeetCode 76: Minimum Window Substring - Python

I'm posting a two-pointer, sliding-window problem of LeetCode (Minimum Window Substring) solved with Python. If you have time and would like to review the code, please do so, I appreciate that. On ...
Emma's user avatar
  • 3,542
1 vote
1 answer
310 views

LeetCode 76: Minimum Window Substring

I'm posting an sliding window problem of LeetCode (Minimum Window Substring) with C++. If you have time and would like to review the code, please do so, I appreciate that. On LeetCode, we are only ...
Emma's user avatar
  • 3,542
0 votes
1 answer
174 views

LeetCode 76: Minimum Window Substring - Java

I'm posting my Java code for the Minimum Window Substring. If you have time and would like to review, please do so, I appreciate that. Problem Given a string string...
Emma's user avatar
  • 3,542
1 vote
1 answer
211 views

Speeding up pandas apply

I would like to speed up pandas apply function. I have been using swifter . It currently takes about 5 mins for 200000 records using multiprocessing as below . Is there any way to speed this up ...
abhilash Dasari's user avatar
2 votes
1 answer
72 views

Count "Word Order" with further optimization

Question: You are given n words. Some words may repeat. For each word, print its number of occurrences. The output order should correspond with the input order of ...
Yozachar's user avatar
  • 227
4 votes
2 answers
286 views

Maxcounters in JavaScript

I am trying to solve this question: MaxCounters. Solving it is straightforward, but solving it fast enough is proving very difficult. How can I improve the performance of this code? At the moment it ...
jackdaw's user avatar
  • 143
5 votes
4 answers
529 views

LeetCode: Roman to Integer in Java

I tried solve this easy leetcode challenge in java. Challenge link Here is my solution ...
srk's user avatar
  • 608
0 votes
2 answers
1k views

Sherlock and Anagrams in Javascript

I am trying to solve a Hackerrank problem Sherlock and Anagrams. I think my code is valid but somehow times out for some of the test cases. Any tips on how to improve its performance? Critique ...
leonheess's user avatar
  • 161
8 votes
3 answers
281 views

Refactor the code which performs "cross-product", "reduce", "product of list" and "sum of list"

I have come up with a sequence of steps to find the maximum product of y positive numbers which add up to x. But the program is ...
Yozachar's user avatar
  • 227
1 vote
3 answers
284 views

ProjectEuler.net problem #50, Consecutive Prime Sum

I am trying to solve ProjectEuler.net problem #50, Consecutive Prime Sum. Here is the problem: The prime 41, can be written as the sum of six consecutive primes: ...
Denis Arbogast's user avatar

1
2
3 4 5
13