Looking for good programming challenges?

Use the search below to find our solutions for selected questions!

Archive for July 2017

Build power set of set

Problem statement Given a set of distinct integers, , return all possible subsets. Note: The solution set must not contain duplicate subsets. Sample input [1, 2, 3] Sample output [[], [3], [2], [2, 3], [1], [1, 3], [1, 2], [1, 2, 3]] Full code class Solution(object): def subsets(self, nums): “”” . . . Read more

Swap list nodes in pairs challenge

Problem statement Given a linked list, swap every two adjacent nodes and return its head. For example: Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. Full code . . . Read more

Container with most water challenge

Problem statement Given n non-negative integers , where each represents a point at coordinate . vertical lines are drawn such that the two endpoints of line is at and . Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You . . . Read more

Merge overlapping intervals challenge

Problem statement Given a set of intervals in any order merge the overlapping intervals and return the list of merged intervals. Sample input [{6,8} {2,4} {1,3} {5,5} {-1,4} {3,4} {6,8} {8,10}] Sample output [{-1,4} {5,5} {6,10}] Solution The first step we are going to take is sort the intervals in . . . Read more

KnightL on a chessboard challenge

Problem statement is a chess piece that moves in an shape. We define the possible moves of as any movement from some position to some satisfying either of the following: and , or and Note that and allow for the same exact set of movements. For example, the diagram below . . . Read more

Longest contiguous increasing subarray

Problem statement Given an array with numbers print a longest increasing subarray in . Sample Input 1 2 3 0 5 19 23 45 -1 -2 10 Sample Output 0 5 19 23 45 Solution We want to solve this problem in time complexity. The easiest approach is to to . . . Read more

Renewing Let’s Encrypt SSL certificate

The other day I have received an email from the Let’s Encrypt Expiry Bot stating that my SSL certificate for the domain name lucaslouca.com is about to expire. In this post I have extensively described how to setup a WordPress blog on an EC2 instance along with a Let’s Encrypt . . . Read more