Home
Nguyen Tai
Cancel

Leetcode 165. Compare version number

Problem Leet code problem 165 Difficulty: Medium Solution Split each version into arrays of revisions using string.split(\\.) version1: 1.0.01 -> ["1", "0", "01"] version2: 1.0 -&gt...

Leetcode 881. Boats to save people

Problem Leet code problem 881 Difficulty: Medium — Solution Implementation Code from github First approach (HashMap) public class L2441_LargestPositiveIntegerThatExistsWithItsNegative { public...

Leetcode 2441. Largest Positive Integer That Exists With Its Negative

Problem Leet code problem 2441 Difficulty: Easy — Solution Initial approach Utilize HashMap, iterate the whole array, for each item add it to the map. Each item should have one of the following val...

Leetcode 2114. Maximum Number of Words Found in Sentences

Leet code problem 2114 Difficulty: Easy — Solution This is pretty straight forward. You can just count the number of words text.split(" ") Or count the spaces between letters because the quest...

Leetcode 35. Search Insert position

Leet code problem 35 Difficulty: Easy — Solution The question mentioned that the complexity must be Olog(n) and it’s a search algorithm We can clearly see that one of the way to solve this is ...

Binary Search

Image from GeeksForGeeks #binary_search, #binary_chop, #half_interval_search, #logarithmic_search Condition The data structure must be sorted Can access to any item in the data structure...

Leetcode 26. Remove Duplicates from Sorted Array

Leet code problem 26 Difficulty: Easy — Solution Use 2 variables curIndex & uniqueCount Iterate the whole nums array using curIndex. If there are any different between current and previous...

Leetcode 1047. Remove All Adjacent Duplicates In String (Loại bỏ tất cả các bản sao liền kề trong chuỗi)

Leet code problem 1047 Difficulty: Easy — Given Chuỗi String chứa các ký tự tiếng Anh viết thường Expectation Loại bỏ toàn bộ các cặp ký tự thoả mãn 2 yêu cầu sau Sắp xếp liền kề Giống nhau ...

Leetcode 20. Valid Parentheses (Tìm cặp dấu ngoặc hợp lệ)

Leet code problem 20 Difficulty: Easy — Given Một chuỗi chứa toàn bộ các ký tự '[', ']', '(', ')', '{', '}' Expectation Kiểm tra tính hợp lệ của chuỗi được test, chuỗi được xét là hợp lệ khi M...

Leetcode 104. Maximum Depth of Binary Tree (Chiều cao tối đa của cây nhị phân)

Leet code problem 104 Difficulty: Easy — Given Cây nhị phân Expectation Chiều cao tối đa của cây nhị phân này Solution Recursive Yêu cầu của bài toán có thể được hiểu là tìm số node tối đa đếm ...