increasing entropy of the universe



Posts Tagged “leetcode”

Mon 17 Jan 2022

Leetcode - Longest Substring Without Repeating Characters

In this [leetcode](https://leetcode.com/problems/longest-substring-without-repeating-characters/) problem, we’re asked to find the length of the longest string of characters in a provided string that does not contain repeating characters. In other words, in the string `abcabcbb` the longest substring without repeating characters is `abc` (with a length of 3)...

Continue reading → leetcode two pointers set



Tue 21 Dec 2021

Course Schedule Leetcode Solution

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai...

Continue reading → leetcode graph bfs java python



Sat 18 Dec 2021

Remove-all-adjacent-duplicates-in-string-ii Solution

You are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing the left and the right side of the deleted substring to concatenate together...

Continue reading → leetcode stack python java scala javascript



Wed 08 Dec 2021

Lowest Common Ancestor of a Binary Tree

Questions involving the binary tree data structure are very popular in tech interviews, and can be challenging and varied! A binary tree is a data structure consisting of a collection of nodes (starting at a root node), where each node consists of a value (data), together with a directed edges to at most two nodes (the "left child" and "right child"), with the additional conditions that no two edges point to the same node and no edge points to the root. I recently solved an interesting problem on binary tree...

Continue reading → leetcode java python javascript scala



Tue 02 Nov 2021

Coin Change solution leetcode

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...

Continue reading → leetcode dp java python



Sun 12 Sep 2021

Maximum Subarray

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...

Continue reading → leetcode dp java python



Tue 08 Jan 2019

Merge Two Sorted Lists

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

Continue reading → programming leetcode code



Tue 13 Nov 2018

Three Sum Problem Leetcode Solution

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...

Continue reading → leetcode two pointers java