Skip to main content

All Questions

3 votes
1 answer
176 views

Find minimal modulo-sum of pairs from two lists

Recently I appeared for an job challenge organised on HackerEarth. Question: There are two teams T1 and T2. Power of each player is represented in array. The rules of game are as follow. There are ...
Tanmey Rawal's user avatar
2 votes
2 answers
891 views

Convert integer to English words

I was recently asked an interview question with regards to algorithm design. The challenge is as follows: Given a 6 or less digits positive integer (0 - 999999 inclusive), write a function ...
tidiot's user avatar
  • 139
5 votes
1 answer
115 views

An alternative algorithm for sorting a stack using only one additional stack

From "Cracking the Coding Interview": Write a program to sort a stack in ascending order (with biggest items on top). You may use at most one additional stack to hold items, but you may not copy the ...
Michael Wright's user avatar
7 votes
6 answers
2k views

Find max number you can create from an array of numbers

Was asked this in an interview yesterday: You are given an array of numbers (not digits, but numbers: e.g. 9, 23, 184, 102, etc.) - you need to construct the largest number from it. For example: you ...
Maverick Meerkat's user avatar
5 votes
2 answers
113 views

Find minimal number of days to meet all your friends

I was asked this in an interview yesterday: You get an array of segments (segment contains 2 numbers, representing days count (say in a month, but could be in a year, etc.): start, end). You need to ...
Maverick Meerkat's user avatar
4 votes
2 answers
908 views

Find the in-order successor of a given node in a binary search tree

I have an implementation of an algorithm to return the in-order successor of a given node in a binary search tree. We are allowed to assume that each node in the BST has a reference to its parent node....
screeb's user avatar
  • 232
4 votes
2 answers
511 views

Longest Palindromic Substring better approach

I have encountered to this question and applied a brute force algorithm off top of my head and couldn't find a better optimized solution. I was hoping I could get some insight to implement a better ...
Ugur Yilmaz's user avatar
2 votes
1 answer
2k views

Rotate matrix 90 degrees

I recently did problem 1.7 Rotate Matrix in Cracking the Coding Interview. I realized my code is very different than what is in the book and also from what I'm finding online (I'm having trouble ...
stillearning's user avatar
3 votes
1 answer
210 views

Find contiguous integers with a given sum

Introduction This question was asked in a technical interview, I am looking for some feedback on my solution. Given a list of integers and a number K, return which contiguous elements of the list ...
Phaedrus's user avatar
12 votes
3 answers
8k views

Vertically print a list of strings to STDOUT into 3 columns with column lengths as balanced as possible

This was a interview question I struggled with, I am posting my solution hoping to look for more elegant/efficient solutions. Problem: Given a list of strings, print its element out to STDOUT one by ...
Pig's user avatar
  • 355
2 votes
1 answer
1k views

Longest Valid Parentheses

This is the "Longest Valid Parentheses" problem from leetcode.com: Given a string containing just the characters "(" and ")", ...
NinjaG's user avatar
  • 2,539
1 vote
1 answer
920 views

Solving "Quadruple sum" problem using dynamic programming

I am trying to learn dynamic programming using hash table. I was given this the "Quadruple sum" problem from firecode.io as a challenge: Given a sorted array of integers and an integer target, find ...
NinjaG's user avatar
  • 2,539
5 votes
1 answer
2k views

Ukkonen's algorithm for longest common substring search

I am working on a programming interview practice question in Python 3 (on codefights.com). The challenge is to return the length of the longest substring that appears in both of two input strings. The ...
Robert Perrotta's user avatar
10 votes
2 answers
287 views

Python implementation of find_all_indexes

I got asked this question before in an interview. For example, find_all_indexes('ababc', 'abc') returns 2. This Python function ...
NinjaG's user avatar
  • 2,539
4 votes
2 answers
722 views

Checking whether any anagram of a string appears within another string

I have the following code that takes a string t and checks to see if any anagram of t is a substring of ...
Calvin Ellington's user avatar

15 30 50 per page