vishalmx3

vishal.codes

Posted on April 3, 2024

Day 3/366

πŸš€ Today's Learning:

🌟 DSA

  • Finding All Duplicates (Unsorted array) - Leetcode 442
  • Maximum Subarray - Leetcode 53

🌟 Dev

  • Why should you use border:transparent instead of border:none.
  • How to check which HTML version are you using.
  • Difference between HTML4 and HTML5.
  • When to use Tailwind, CSS, SCSS and difference among them.
  • What are pseudo classes.

πŸ” Some Key Highlights:

DSA

Finding All Duplicates (Unsorted array) - Leetcode 442

Brute force

Approach 1 β†’ Iterate through each element β†’ search for its duplicate in rest of the elements to the right β†’ if found push in ans array.
(T.C. - O(n^2) | S.C. - O(1))

Approach 2 β†’ Make a hash table of n elements β†’ Iterate through nums and fill the hashtable with counts of each element β†’ Iterate through hash table and if count > 1 push to ans array.
(T.C. O(n) | S.C. O(n))

Optimized Approach - (T.C. O(n) | S.C. O(1))

β†’ Iterate through nums array β†’ for each element calculate index = abs(nums[i]) -1 (subtracting 1 coz range of element start from 1 so this will always give a valid index) β†’ make nums[index] negative, if already negative it means there was a duplicate who earlier made this number negative, so push this element to ans array.

Image description

Maximum Subarray - Leetcode 53

Brute force

Iterate over all subarrays using 2 nested loops to find the maximum sum among all of them.
(T.C. O(n^2))

Optimized Approach - (T.C. O(n) | S.C. O(1))

β†’ Use Kadane’s algorithm - we carry a subarray sum as long as it gives a positive sum.

β†’ Take currentSum (for calculating the sum of current subarray) and maxSum (for storing the maximum sum so far). If in any iteration, we find currentSum as negative we reset currentSum to 0.

Image description

DEV

  1. Border Styles: Use border: transparent to hide a border while preserving layout, and border: none to completely remove it.
  2. HTML Version Check: Look at the <!DOCTYPE> declaration to determine if it's HTML5 or HTML4.
  3. HTML4 vs. HTML5: HTML5 introduced semantic elements, multimedia support, enhanced forms, and graphics capabilities.
  4. Styling Tools:
    • CSS: Basic styling language.
    • SCSS: Enhanced CSS with variables and mixins.
    • Tailwind CSS: Utility-first framework for rapid UI development.
  5. Pseudo-classes: Keywords for styling based on user interaction or document structure.
πŸ’– πŸ’ͺ πŸ™… 🚩
vishalmx3
vishal.codes

Posted on April 3, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Day 42/366
1percentplusplus Day 42/366

May 12, 2024

Day 41/366
1percentplusplus Day 41/366

May 11, 2024

Day 40/366
1percentplusplus Day 40/366

May 10, 2024

Day 39/366
1percentplusplus Day 39/366

May 9, 2024

Day 38/366
1percentplusplus Day 38/366

May 8, 2024