Valizada's blog

Category: Leetcode

Validate Binary Search Tree

October 26, 2020Leetcode / Algorithms 1 Min Read

Link to leetcode problem definition Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as…

35. Search Insert Position - June day 10

June 10, 2020Leetcode / Algorithms 1 Min Read

Link to leetcode problem definition Given a sorted array and a target value, return the index if the target is found. If not, return the…

392. Is Subsequence - June day 9

June 09, 2020Leetcode / Algorithms 1 Min Read

link to leetcode problem definition Given a string s and a string t, check if s is subsequence of t. A subsequence of a string is a new…

237. Delete Node in a Linked List - June day 2

June 07, 2020Leetcode / Algorithms 1 Min Read

Linked list problem that can be solved in O(1) Write a function to delete a node (except the tail) in a singly linked list, given only…

518. Coin Change 2 - June day 7

June 07, 2020Leetcode / Algorithms 3 Min Read

link to leetcode problem definition You are given coins of different denominations and a total amount of money. Write a function to compute…

Leetcode June Challenge

June 07, 2020Leetcode 1 Min Read

In these series I will be posting my solutions to leetcode questions from June challenge. Navigate to the linked pages below to read…

406. Queue Reconstruction by Height - June day 6

June 07, 2020Leetcode 1 Min Read

Link to leedcode problem definition Suppose you have a random list of people standing in a queue. Each person is described by a pair of…

226. Invert Binary Tree - June day 1

June 07, 2020Leetcode / Algorithms 2 Min Read

Inspiration of this problem comes from Max Howel's interview experience with Google described in this tweet. Lets jump to the problem The…

344. Reverse String - June day 4

June 07, 2020Leetcode / Algorithms 1 Min Read

link to leedcode problem definition Write a function that reverses a string. The input string is given as an array of characters char[]. Do…

1029. Two City Scheduling - June day 3

June 07, 2020Leetcode 1 Min Read

link to leetcode problem definition There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is…

343. Integer Break, leetcode - dynamic programming

May 23, 2020Leetcode / Algorithms 1 Min Read

Another interesting leetcode problem that comes up often in Apple and Google interviews. Given a positive integer n, break it into the sum…

343. Integer Break, leetcode - Recursion, memoization

May 23, 2020Leetcode / Algorithms 2 Min Read

Another interesting leetcode problem that comes up often in Apple and Google interviews. Given a positive integer n, break it into the sum…

1448, Count Good Nodes in Binary Tree - BFS

May 17, 2020Leetcode / Algorithms 1 Min Read

Nice graph problem from leetcode biweekly contest. As majority of graph problems this one can be solved with Breadth First Search as well…

Form largest integer with digits that add up to target leetcode dynamic programming

May 17, 2020Leetcode / Algorithms 6 Min Read

Dynamic programming solutions are just a pleasure to read! Here is another one from Biweekly leetcode contest 26 to a problem that can be…

1447 Simplified Fractions, Leetcode

May 17, 2020Leetcode / Algorithms 2 Min Read

1447 Simplified fractions Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the…

Maximal Square

April 28, 2020Leetcode / Algorithms 2 Min Read

Another mind blowing solution with dynamic programming to LeetCode problem number 26 from 30 day challenge Problem statement: Given a 2D…