Skip to main content

All Questions

222 votes
4 answers
24k views

Calculate SHA1 hash from binary and verify with a provided hash

I applied for a job and they asked me to write code with the following requirements: Get a "toolbar offer" description from http..update.utorrent.com/installoffer.php?offer=conduit. Parse the ...
user26614's user avatar
  • 2,209
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
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
8 votes
2 answers
6k views

Determine if string has all unique characters

I'm working my way through the exercises of the book Cracking the Coding Interview. I'd like to review my solution for the question: Implement an algorithm to determine of a string has all unique ...
DJanssens's user avatar
  • 1,460
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
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
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
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
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
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
3 votes
2 answers
490 views

Largest subarray with sum equal to 0

This is a typical interview question: Given an array that contains both positive and negative elements without 0, find the largest subarray whose sum equals 0. I am not sure if this will satisfy all ...
Arman's user avatar
  • 313
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
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
3 votes
1 answer
94 views

Sum to zero of all triples in a list - n^2 running time

As part of an interview, I had to submit a code sample to solve the classical "triples sum to 0" problem. The reviewer said the algorithm needed to be in n2 time, and I was later informed that the ...
dj_bushido's user avatar

15 30 50 per page