Categories
-
Recent Posts
Recent Comments
Tags
- a-ha moment
- algorithms
- anagrams
- binary trees
- birthday pairings
- Dynamic Programming
- finance
- geometric progressions
- graphs
- interview questions
- linked lists
- logarithms
- mathematics
- monte carlo
- numpy
- permutations
- prime numbers
- probability
- programming
- puzzle
- puzzles
- python
- quants
- recursion
- shortest path
- simulations
- stirling's approximation
- yield curves
- zero curves
November 2024 M T W T F S S « Mar 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Archives
Meta
Tag Archives: interview questions
Cyclic Linked List – finding the start of the loop using Python
I’d blogged previously about writing a python function to find out whether a linked list is cyclic or acyclic – it’s worth a read before tackling this one. The challenge here is to return the node that is at the … Continue reading
Puzzle – A safe place to drop an egg
This is a problem where it’s fairly easy to find the solution via trial and error, but not so easy to generalize. Question Let’s say you need to find out the highest floor in a 100 story building from which … Continue reading
Alternating coin toss – redux
I want to revisit a probability puzzle from a previous post: see Alternating coin toss game. You play a game where you alternate tossing a coin with a friend, and the first person to toss heads wins. But let’s make … Continue reading
Puzzle – Break a stick to get a triangle
I read somewhere this is a Google interview question: Let’s say you drop a stick, breaking it randomly in 2 places, leaving you with 3 smaller sticks. What’s the probability you can make a triangle out of the 3 resulting … Continue reading
Puzzle – shortest road system
Let’s say you’re contracted to build roads to connect four towns that are at the corners of an imaginary square with sides 1 mile. What’s the shortest length of road system you can build so that every town can get … Continue reading
Puzzle – Clock
It’s 3 O’Clock. What will be the time when the minute and hour hands are next in the same position (coincident)? One way to solve this problem: start with the minute hand at the 12 and hour hand at the … Continue reading
More puzzles…
Some of these are from Heard on the Street – a book of interview questions for Quants I’m trying to get through. Well worth a read if you’re into this sort of thing… 1. Two ropes of different lengths, and … Continue reading
Mth to last – a recursive approach in Python
A collegue of mine was pondering the mthToLast problem for a LinkedList I’d blogged about previously and sent me the following IM message: just a guess – but can you use recursion to solve your link list m problem? a … Continue reading
Reverse a string using recursion in Python
I’ve always found recursion somewhat unnatural to think about, but somehow satisfying when I can see it unfolding in my mind – this simple exercise in reversing a string using recursion is a case in point… >>> def reverse(str): if … Continue reading
Deep copy and recursive references
Quick one about coding a deep copy and avoiding recursive references… Let’s say we have an instance a which has a reference to an instance b and we have to do a deep copy of a. To do this, we … Continue reading