HackerRank – Zig Zag Sequence solution

In this article, I’ll explain the Zig Zag Sequence algorithm problem on HackerRank. Problem statement: You’re given an integer array with an odd number of elements (ex: [5, 2, 3, 1, 4]). You need to re-arrange the elements so they’re in a zig zag sequence, which means: Here’s a diagram to help you visualize what … Read more

HackerRank – Mark and Toys solution

In this article, I’ll explain how to solve the Mark and Toys algorithm problem on HackerRank. Problem statement: Given a fixed budget and a list of item prices. What is the max number of items you can purchase? You can only buy each item once. Note: This is the Mark and Toys problem from HackerRank. … Read more

HackerRank – Two Strings solution

In this article, I’ll explain how to solve the Two Strings algorithm problem on HackerRank. Problem statement: Given two strings, determine if they have a substring in common. The strings can have up to 100k characters. Example: Given “hello world” and “world”, do they have a substring in common? Yes, they many substrings in common. … Read more

HackerRank – Sock Merchant solution

In this article, I’ll explain how to solve the Sock Merchant algorithm problem on HackerRank. Problem statement: You’re given an integer array and need to count the number of pairs of matching integers. The integers will be between 1 and 100. For example, [3,1,3] has one matching pair (the 3s match). Approach First, we know … Read more