# Ngày 04/06 ## Vương Test -- Demo merge code ## Hiếu ### Icon Button ![](https://i.imgur.com/ux9hvIt.png) ![](https://i.imgur.com/LsVWxuh.png) ![](https://i.imgur.com/PDozUwS.png) ### DatePipe in ts [DatePipe Demo](https://stackblitz.com/edit/date-pipe-format-error-ex6fiu?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.css,src%2Findex.html,src%2Fapp%2Fhello.component.ts) ### Bài số 1 **Example 1:** Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] **Example 2:** Input: nums = [] Output: [] **Example 3:** Input: nums = [0] Output: [] ```typescript= function threeSum(nums: number[]): number[][] { let res = []; nums.sort((a, b) => a - b); for (let i = 0; i < nums.length - 2; i++) { if (nums[i] > 0) break; //Mảng đã sắp xếp từ bé đến lớn //Nếu phần tử đầu tiên của mảng > 0 dừng chương trình luôn if (i > 0 && nums[i] === nums[i - 1]) continue; //since the array is sorted, we can check the number right before our value //to see if we have seen it already let l = i + 1; let r = nums.length - 1; while (l < r) { let sum = nums[i] + nums[l] + nums[r]; if (sum > 0) { r--; //since the array is sorted, decrementing r will result in a smaller sum } else if (sum < 0) { l++; //since the array is sorted, incrementing l will result in a larger sum } else { res.push([nums[i], nums[l], nums[r]]); l++; while(l < r && nums[l] === nums[l - 1]) l++; //to ignore duplicates, we increment l until another unique value is found } } } return res; }; ```