Tagged Questions
Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.
0
votes
0answers
8 views
How can i make this code more efficient?
it solves the problem listed here - https://www.hackerrank.com/challenges/dynamic-array
...
-2
votes
0answers
19 views
Restaurant Practice Problem on Hackerrank [on hold]
I was solving a problem on HackerRank, whose statement is given below:
Martha is interviewing at Subway. One of the rounds of the interview requires her to cut a bread of size into smaller identical ...
2
votes
0answers
22 views
Finding the maximal bottleneck in a 2D matrix from source to destination
I recently started solving programming challenges and this one is causing me performance trouble. The problem statement is the following:
You are given a 2d matrix where each cell contains an ...
6
votes
1answer
85 views
Find the shortest path through a maze with a twist: you can knock down one wall
I would like my solution to Google Foobar's prepare_the_bunnies_escape checked for readability, maintainability, extensibility, style, design. I am looking forward ...
2
votes
2answers
57 views
Leetcode 49: Group Anagrams - Hash function design talk
problem statement
Given an array of strings, group anagrams together.
For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"],
Return:
[
["ate", "eat","tea"],
["nat","...
2
votes
3answers
71 views
LeetCode 49: Group Anagrams
I'm exceeding the time limit for a 10,000 word test case provided on LeetCode:
Given an array of strings, group anagrams together.
For example, given: ...
3
votes
2answers
65 views
Find most occurred number in sorted array of numbers
I was asked in an interview to find the a number in an sorted array of numbers which has occurred maximum number of times. Also find the count of occurrence of that number.
I solved it in javascript,...
0
votes
2answers
94 views
Spiral printing of 2D matrix
Please comment about code complexity, and coding style, I'm preparing for a code interview, so any comment would be appreciated.
Example:
Input
...
6
votes
2answers
1k views
Magic Trick (Google Code Jam 2014 QR Problem A) in Python
I'm learning Python by solving previous GCJ problems. This problem is quite simple to solve, but I'd like my code to be reviewed for advance (more Pythonic expression and more efficient algorithm).
...
2
votes
4answers
46 views
Counting pairs of numbers that differ by a given amount
I am trying to do these online competitions where you get the given exercise and are supposed to upload the source file.
The site is not in English so I will try to summarize the exercise.
The first ...
-8
votes
0answers
37 views
C Programming,, kindly help me out [on hold]
Here is a c Program related query...kindly crack it and help me guys...
(https://i.stack.imgur.com/ym3Fo.jpg)
2
votes
1answer
77 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\$, ...
0
votes
0answers
24 views
Time limit exceeded, Python creat binary tree [closed]
I am doing a coding challenge of google foobar by the online judgement platform.
When I run my python code I always get TLE: Time Limit Exceeded
It works well when I run it in local using python ...
1
vote
0answers
88 views
Implementation of Wagner-Fischer-algorithm
I'm working on an implementation of a Wagner-Fischer-Algorithm for an online programming challenge site, but I can't seem to push the time down to where it needs to be. The assignment is to, for a ...
1
vote
1answer
72 views
Leetcode 210. Course Schedule II
Problem statement
There are a total of \$n\$ courses you have to take, labeled from
\$0\$ to \$n - 1\$.
Some courses may have prerequisites, for example to take course \$0\$
you have to ...
10
votes
1answer
122 views
Hackerrank Queen's Attack II
Problem statement
A queen is standing on an \$n\$x\$n\$ chessboard. The chessboard's rows are numbered from \$1\$ to \$n\$, going from bottom to top; its columns are numbered from \$1\$ to \$n\$, ...
2
votes
3answers
161 views
Project Euler: Longest Collatz Sequence
The Collatz Sequence is an iterative sequence that is defined for all positive integers as such:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
If 13 were to be entered into this sequence, the result ...
4
votes
2answers
62 views
Matched Brackets challenge
I am attempting the matched brackets problem. I have written a Python program which seems to do the job but is very slow and thus exceeds the time limit. Please help me making this code more efficient....
3
votes
1answer
70 views
Parallel brute-force solution for Project Euler 4 (Largest palindrome product)
The pe4Concurrent.go file given below is my first attempt at writing a concurrent programme, pe4.go is a non-concurrent implementation of the same algorithm for comparison purposes.
The algorithm ...
4
votes
3answers
75 views
Checking whether if start and end has equal number of non-zero integers and contains 3 or more 0 in the center
An array is said to be hollow if it contains 3 or more zeros in the
middle that are preceded and followed by the same number of non-zero
elements. Write a function named ...
4
votes
2answers
63 views
Segmented Sieve of Eratosthenes
I implemented this for the Prime Generator problem on SPOJ, but I am only getting 0.01s run-time, and would like to be able to match the run-times of the top submissions, which are all 0.00s.
What ...
1
vote
0answers
105 views
Hackerrank: Sherlock and anagram
Problem statement
Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings.
Input Format
First line contains \$T\$, the number of testcases. Each testcase ...
8
votes
3answers
133 views
Leetcode 56: Merge Intervals
Problem statement
Given a collection of intervals, merge all overlapping intervals.
For example:
Given \$[1,3],[2,6],[8,10],[15,18]\$,
return \$[1,6],[8,10],[15,18]\$.
My ...
1
vote
1answer
61 views
Project Euler problem 2 in Haskell
I have just started Haskell, and I want to check if my code is following the spirit of the language.
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find ...
1
vote
1answer
41 views
Hackerrank Gemstones Solution
I'm looking for any possible improvements in terms of memory usage and speed, but really any advice is welcome.
Problem statement:
John has discovered various rocks. Each rock is composed of ...
4
votes
2answers
333 views
CodeWars: Gap in Primes
I wrote a javascript code for finding the first two consecutive prime numbers (that doesn't have divisors except one and itself) with a specific gap between them. It works well but take too much time ...
3
votes
2answers
94 views
4 sum challenge (part 2)
This is a continued discussion from (4 sum challenge) by return count only.
Problem
Given four lists A, B, C, D of integer values, compute how many tuples
(i, j, k, l) there are such that A[...
6
votes
2answers
132 views
Find K biggest numbers in the array
I was trying to implement method number 2, from this article.
Method 2 (Use temporary array) K largest elements from arr[0..n-1]
Store the first k elements in a temporary array temp[0..k-1]....
7
votes
1answer
109 views
Hackerrank - value of friendship (II)
Problem statement
You're researching friendships between groups \$n\$ of new college students where each student is distinctly numbered from \$1\$ to \$n\$. At the beginning of the semester, no ...
4
votes
1answer
91 views
Shortest Path For Google Foobar (Prepare The Bunnies Escape)
I have been working on Google Foobar since a few days ago. I am currently in the third level but is stuck in the second challenge of "Prepare the Bunnies' Escape."
I have checked this post but it did ...
4
votes
1answer
72 views
Assembly Line Scheduling challenge, solved using TDD
I am new to Test Driven Development and currently practicing it with some problem statement. Following is an Assembly Line Problem statement I solved using TDD approach in java. Please provide me some ...
8
votes
1answer
204 views
+50
Selecting kids for a Christmas play with similar heights
I am doing this problem on SPOJ. The challenge is :
My kid's kindergarten class is putting up a Christmas play. (I hope he gets the lead role.) The kids are all excited, but the teacher has a ...
3
votes
1answer
77 views
Request for memory optimizations for solution to Google FooBar challenge, “ion_flux_relabeling,”
I just finished one of the Google FooBar Challenges.My Python is super rusty. I did the challenge in Haskell first and then attempted to covert the code. I am guessing that led to some bad Python ...
4
votes
0answers
90 views
4 sum challenge
Problem
Given four lists A, B, C, D of integer values, compute how many tuples
(i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.
To make problem a bit easier, all A, B, C,...
5
votes
2answers
90 views
Project Euler solution #2 using Swift 3
I just wanted some review and opinions. Any better implementations or suggestions would be great.
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting ...
5
votes
1answer
178 views
Hackerank - value of friendship
Problem statement
You're researching friendships between groups \$n\$ of new college students where each student is distinctly numbered from \$1\$ to \$n\$. At the beginning of the semester, no ...
3
votes
2answers
107 views
Create index-less array product
Source: careercup.com
You are given an array of integers(with all valid input) You have to
write a function which will produce another array, where the value in
each index of the array will be ...
3
votes
1answer
62 views
Assignement on reading from stdin in C
I am an experienced Python developer learning C. I solved this assignement:
Write a program that reads a word and some sentences from stdin. The word is separated by space from a sentences. The ...
1
vote
1answer
42 views
Codewars Challenge Kata
I was recently doing a challenge on Codewars and this is what challenge said:
There are no explanations. You have to create the code that gives the
following results:
...
3
votes
2answers
82 views
Finding Permutations of Numbers
I'm trying to solve this challenge, which consists of finding the next biggest number formed by the digits of the passed in number. If it is impossible to find a number larger than the passed in ...
0
votes
2answers
233 views
Capital Movement CodeChef challenge [closed]
PROBLEM
Suppose there are 'n' cities in a country out of which, one is the
capital. All of the cities are connected through 'n-1' roads so that
it's possible to travel between any two cities ...
2
votes
1answer
123 views
Merchant's Guide to the Galaxy
This is my version of Merchant's Guide to the Galaxy:
A merchant buys and sells items in the galaxy. Buying and selling over
the galaxy requires you to convert numbers and units. The numbers used
...
1
vote
2answers
62 views
Delta encoding a list of numbers
Given a list of numbers, e.g.:
25626 25757 24367 24267 16 100 2 7277
Output a delta encoding for the sequence. In a delta encoding, the first
element is ...
2
votes
1answer
55 views
Ashton and String Hackerrank
Online coding challenge Hacker Rank.
I tried to solve it using the naive appraoch first but its failing on some of the inputs and rest its getting timed out. How to get started in problem like these ...
3
votes
1answer
102 views
Find kth largest element in the union of two sorted array
Problem statement:
Find \$kth\$ largest element in the union of two sorted array.
My introduction of the algorithm
I spent a few hours to review two algorithms, Leetcode 4:Median of Two Sorted Arrays ...
2
votes
0answers
80 views
Hackerearth Simple Function - Follow-up
Problem statement
Let us first describe a SimpleFunction:
...
2
votes
1answer
114 views
Build String Hackerrank
Online challenge on Hacker Rank.
Please follow the description from the above link.
...
7
votes
3answers
270 views
Sort Characters By Frequency
I solved this problem.
Problem Statement
Given a string, sort it in decreasing order based on the frequency of
characters.
Example 1
Input: "tree"
Output: "eert"
...
3
votes
1answer
39 views
Trim to the nearest word under limit
Given a text and the length limit I need to trim the text to the word which is nearest to the limit.
...
5
votes
1answer
75 views
Custom Big Integer class for Project Euler in C#
I'm trying to teach myself some programming and, working through the Project Euler problems, I've come across some instances where I've needed numbers that are larger than will fit into an int or long ...