DEV Community

vishal.codes
vishal.codes

Posted on

Day 7/366

🚀 Today's Learning:

🌟 DSA

  • Validate a string
  • Reversing a string

🌟 Dev

  • Difference b/w and
  • Newly introduced feautures in HTML5.

🔍 Some Key Highlights:

DSA

Validate a string

→ A string is valid if it only contains letters and numbers (No special characters should be present) → Iterate through the string and for each pass check if (!(s[i] ≥ 65 && s[i] ≤ 90) && !(s[i] ≥ 97 && s[i] ≤ 122) && !(s[i] ≥ 48 && s[i] ≤ 57)). So if any of the condition to the check letters and numbers fail return false, otherwise return true.

Reversing a string

Approach 1 → Iterate through the string and move i to last element → now reverse travel original array and copy each element in the new array. Return the new array. (T.C. O(n) | S.C. O(n))

Approach 2 → Take two pointers i and j. i starts from first character of string and j from last. They both move towards each others and swap characters at each pass (till i<j). (T.C. O(n) | S.C. O(1))

DEV

The onload executes a block of code after the page is completely loaded while $(document).ready(function) executes a block of code once the DOM is ready.

Input types, including Date, Date Time-local, time, week, month, email, tel, URL, search, range, color, and number, are among the new ones introduced by HTML5. to enhance user interaction and make forms more engaging. However, a browser will interpret these new input types like a standard text box if it is unable to recognize them.

#100daysofcode #1percentplusplus #coding #dsa

Top comments (0)