RomeoFantastik's blog

By RomeoFantastik, history, 5 years ago, In English

Day 3 got to an end and the best problem of day 3 was by far "132 Pattern" from Leetcode, simple but amazing problem. Here is me solving the problem of the day: https://www.youtube.com/watch?v=pqCy9Z4x4qs&feature=youtu.be

Given a sequence of n integers a[1], a[2], ..., a[n], a 132 pattern is a subsequence a[i], a[j], a[k] such that i < j < k and a[i] < a[k] < a[j]. Design an algorithm that takes a list of n numbers as input and checks whether there is a 132 pattern in the list.

This problem is our introduction to the Stack data structure. Amazing interview question, we are going through 3 brute force approaches until getting to the final idea in linear time.

Join the Competitive Programming and Interview Questions Mastermind on Facebook for daily challenges, tips and tricks and sharing experiences: https://www.facebook.com/groups/453242718909088

  • Vote: I like it
  • -9
  • Vote: I do not like it