Manh PhanPractice makes perfect!
http://ducmanhphan.github.io
Leetcode 153 - Find Minimum in Rotated Sorted Array
Table of contents Given problem Using Binary Search algorithm Wrapping up Given problem Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it was rotated 4 times. [0,1,2,4,5,6,7] if it was...
Thu, 26 May 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-05-26-leetcode-153-find-minimum-in-rotated-sorted-array/
http://ducmanhphan.github.io/2022-05-26-leetcode-153-find-minimum-in-rotated-sorted-array/Leetcode 1348 - Tweet Counts Per Frequency
Table of contents Given problem Analyze our problem Using Binary Search algorithm Using TreeMap data structure Using TreeSet data structure Wrapping up Given problem A social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These...
Wed, 18 May 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-05-18-leetcode-1348-tweet-counts-per-frequency/
http://ducmanhphan.github.io/2022-05-18-leetcode-1348-tweet-counts-per-frequency/Leetcode 1346 - Check If N and its Double Exists
Table of contents Given problem Using Brute-force solution Using Binary Search algorithm Using other solutions Wrapping up Given problem Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M). More...
Mon, 16 May 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-05-16-leetcode-1346-check-if-n-and-its-double-exist/
http://ducmanhphan.github.io/2022-05-16-leetcode-1346-check-if-n-and-its-double-exist/How to convert int[] to List of Integer
Table of contents Given problem Using Arrays utitlity class Using Collections class Using the traditional for loop Wrapping up Given problem When we work on some projects, or practice coding in LeetCode, sometimes we need to do conversion from int[] to List<Integer>. This is a tedious task. Normally, we will...
Sun, 17 Apr 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-04-17-how-to-convert-int-to-list-integer/
http://ducmanhphan.github.io/2022-04-17-how-to-convert-int-to-list-integer/Leetcode 950 - Reveal Cards In Increasing Order
Table of contents Given problem Using Deque data structure Wrapping up Given problem You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the ith card is deck[i]. You can order the deck in any order you...
Sun, 10 Apr 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-04-10-leetcode-950-reveal-cards-in-increasing-order/
http://ducmanhphan.github.io/2022-04-10-leetcode-950-reveal-cards-in-increasing-order/Leetcode 1823 - Find the Winner of the Circular Game
Table of contents Given problem Using Circular Linked List Using Queue Wrapping up Given problem There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings...
Thu, 07 Apr 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-04-07-leetcode-1823-find-the-winner-of-the-circular-game/
http://ducmanhphan.github.io/2022-04-07-leetcode-1823-find-the-winner-of-the-circular-game/Leetcode 1413 - Minimum value to get positive step by step sum
Table of contents Given problem Using brute force algorithm Using prefix sum technique Using binary search algorithm Using Kadane algorithm Wrapping up Given problem Given an array of integers nums, you start with an initial positive value startValue. In each iteration, you calculate the step by step sum of startValue...
Thu, 07 Apr 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-04-07-leetcode-1413-minimum-value-to-get-positive-step-by-step-sum/
http://ducmanhphan.github.io/2022-04-07-leetcode-1413-minimum-value-to-get-positive-step-by-step-sum/Leetcode 1700 - Number of Students Unable to Eat Lunch
Table of contents Given problem Using brute force algorithm Optimized the above solution Wrapping up Given problem The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches....
Sat, 02 Apr 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-04-02-leetcode-1700-number-of-students-unable-to-eat-lunch/
http://ducmanhphan.github.io/2022-04-02-leetcode-1700-number-of-students-unable-to-eat-lunch/Leetcode 933 - Number of Recent Calls
Table of contents Given problem Using Queue Using Binary Search algorithm Wrapping up Given problem You have a RecentCounter class which counts the number of recent requests within a certain time frame. Implement the RecentCounter class: RecentCounter() Initializes the counter with zero recent requests. int ping(int t) Adds a new...
Fri, 01 Apr 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-04-01-leetcode-933-number-of-recent-calls/
http://ducmanhphan.github.io/2022-04-01-leetcode-933-number-of-recent-calls/Rete algorithm
Table of contents Given problem Solution with Rete algorithm The differences between Rete algorithm and Brute force approach When to use Benefits and Drawbacks Some questions about Rete algorithm Source code Wrapping up Given problem This article will be used to note everything about the simple version of Rete algorithm...
Thu, 31 Mar 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-03-31-rete-algorithm/
http://ducmanhphan.github.io/2022-03-31-rete-algorithm/Leetcode 102 - Level Order Traversal
Table of contents Given problem Using recursive version Using iterative version When to use Wrapping up Given problem Given a binary tree, return the level order traversal of its node’s value. The output of the above binary tree is: 1 --> 2 --> 3 --> 4 --> 5 --> 6...
Wed, 30 Mar 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-03-30-leetcode-102-level-order-traversal/
http://ducmanhphan.github.io/2022-03-30-leetcode-102-level-order-traversal/How To Use Multiple Github Accounts In Windows
Table of Content Given Problem Some steps to use multiple Github accounts on the same machine Wrapping up Given Problem Currently, we have multiple accounts on the same host - https://github.com/. It’s difficult to work on lots of projects at the same time. Because it can cause the issue of...
Tue, 15 Mar 2022 00:00:00 -0700
http://ducmanhphan.github.io/2022-03-15-how-to-use-multiple-github-accounts-in-windows/
http://ducmanhphan.github.io/2022-03-15-how-to-use-multiple-github-accounts-in-windows/Domain Model Pattern
Table of contents Given problem Solution with Domain Model pattern When to use Benefits and Drawbacks Wrapping up Given problem We knew that 3-layer architecture can be depicted as the following image. The Domain layer wil contain the business logic that implements some operations such as validation, business rules, …...
Tue, 13 Jul 2021 00:00:00 -0700
http://ducmanhphan.github.io/2021-07-13-domain-model-pattern/
http://ducmanhphan.github.io/2021-07-13-domain-model-pattern/Understanding about RESTful system
Table of contents Given problem Solution of using RESTful system Idempotency in RESTful API HATEOAS constraints in RESTful API Benefits and Drawbacks Wrapping up Given problem In this article, we will find out some principles, constraints of RESTful system, and analyze some particular properties that we need to follow. Now,...
Wed, 24 Mar 2021 00:00:00 -0700
http://ducmanhphan.github.io/2021-03-24-understanding-about-restful-system/
http://ducmanhphan.github.io/2021-03-24-understanding-about-restful-system/LeetCode 925 - Long Pressed Name
Table of contents Given problem Using brute force algorithm Using two pointers technique Wrapping up Given problem Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times. You examine...
Thu, 28 Jan 2021 00:00:00 -0800
http://ducmanhphan.github.io/2021-01-28-leetcode-925-long-pressed-name/
http://ducmanhphan.github.io/2021-01-28-leetcode-925-long-pressed-name/Leetcode 905 - Sort array by parity
Table of contents Given problem Using recursion way Using two-pointers technique Wrapping up Given problem Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any answer array that satisfies this...
Wed, 27 Jan 2021 00:00:00 -0800
http://ducmanhphan.github.io/2021-01-27-leetcode-905-sort-array-by-parity/
http://ducmanhphan.github.io/2021-01-27-leetcode-905-sort-array-by-parity/Leetcode 300 - Longest Increase Subsequence
Table of Contents Given problem Using Recursion Using Top-Down approach in DP Using Bottom-up approach in DP Using Binary Search Tree Wrapping up Given problem Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an...
Mon, 25 Jan 2021 00:00:00 -0800
http://ducmanhphan.github.io/2021-01-25-leetcode-300-longest-increase-subsequence/
http://ducmanhphan.github.io/2021-01-25-leetcode-300-longest-increase-subsequence/Leetcode 518 - Coin Change II
Table of contents Given problem Using backtracking Using Stack to optimize the backtracking version Using memoization for backtracking version Wrapping up Given problem You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount....
Sat, 16 Jan 2021 00:00:00 -0800
http://ducmanhphan.github.io/2021-01-16-leetcode-518-coin-change-ii/
http://ducmanhphan.github.io/2021-01-16-leetcode-518-coin-change-ii/Ubiquitous Language in DDD
Table of contents Given problem Solution with Ubiquitous Langage Benefits and Drawbacks Wrapping up Given problem Normally, when creating a base project for an application, we usually use Layered architecture pattern. The drawback of this pattern: We only know the above layer of the business logic, without the underlying concept...
Mon, 04 Jan 2021 00:00:00 -0800
http://ducmanhphan.github.io/2021-01-04-ubiquitous-language-in-ddd/
http://ducmanhphan.github.io/2021-01-04-ubiquitous-language-in-ddd/Leetcode 283 - Move Zeros
Table of contents Given problem Using extra space way Using two-pointers technique Wrapping up Given problem Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] Constraints: You must do...
Sat, 02 Jan 2021 00:00:00 -0800
http://ducmanhphan.github.io/2021-01-02-leetcode-283-move-zeros/
http://ducmanhphan.github.io/2021-01-02-leetcode-283-move-zeros/