๐ 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)