Tue 02 Nov 2021
## Coin Change solution leetcode

Sun 12 Sep 2021## Maximum Subarray

Sat 07 Sep 2019## Recursively sort a array

Tue 08 Jan 2019## Merge Two Sorted Lists

Tue 13 Nov 2018## Three Sum Problem

Sat 22 Aug 2015## Why people like Programming

It's one of the most popular questions on leetcode that seems very easy at first. Coin change is a classic dynamic programming problem. I will proceed with an obvious (albeit wrong) solution and subsequently proceed to an efficient correct solution.

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume that you have an infinite number of each kind of coin...

Continue reading → programming leetcode code dp java python

Sun 12 Sep 2021

There's an interesting problem I recently solved on leetcode based on dynamic programming. My Github repository contains list of all problems that I have solved. I often start with a brute force approach without fretting about time complexity. Later I try to improve my algorithm for a better efficient solution.

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array.^{1}

Continue reading → programming leetcode code dp

Sat 07 Sep 2019

I recently came across a simple telephonic interview problem. The problem was to sort an array recursively. But even numbers need to be placed before odd numbers. At first glance it was obvious that it was a simple case of implementation of merge sort.

**Problem Statement**

Given an input array, produce the following output array…..

Continue reading → programming interview merge sort sort java code

Tue 08 Jan 2019

Merge two sorted linked lists and return it as a new list.^{1}. The new list should be made by splicing together the nodes of the first two lists.

It’s an easy problem in Leetcode for practicing linked list. It’s similar to the merge step of the Merge sort. ..

Continue reading → programming leetcode code

Tue 13 Nov 2018

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.^{1}

Continue reading → programming leetcode code

Sat 22 Aug 2015

Imagine a sunset, with a tired sun sinking over a meadow. The chirping of birds steals your attention as they return to their homes. And while the sun disappears, you sink back and relish your sourrounding.

Well the sunset is beautiful because it’s obvious to your eyes. Similarly programming is beautiful for those who enjoy it. Below is the poem which which eulogises lisp programming language, but it may be bland for those who have no experience with lisp...

Continue reading → programming general