Day 15/366

🚀 Today’s Learning:

🌟 DSA

  • Sentence Palindrome
  • Longest Substring Without Repeating Characters

🌟 Dev

  • Asynchronous JS

🔍 Some Key Highlights:

DSA

Sentence Palindrome:

To determine if a sentence is a palindrome, we can utilize a recursive approach. We begin by processing the current sentence, which involves removing any spaces and converting all characters to lowercase to ensure case insensitivity. Then, we check if the processed sentence is a palindrome by comparing the characters at the beginning and end of the sentence. If they match, we continue checking the inner characters recursively until either the sentence becomes empty or we find a mismatch. If all characters match, the sentence is a palindrome.

Longest Substring Without Repeating Characters:

For finding the longest substring without repeating characters, we employ a sliding window approach. We start by initializing two pointers, one at the beginning and the other at the end of the string. As we process the string, we maintain a set or a hashmap to keep track of characters encountered within the current window. If we encounter a repeating character, we shrink the window from the left side until the repeating character is no longer in the window. Meanwhile, we keep track of the maximum length of the window encountered so far. We continue this process until we reach the end of the string, ensuring that each substring within the window contains unique characters. Finally, the length of the longest substring without repeating characters is the maximum length encountered during the process.

DEV

Asynchronous Programming in JavaScript:

JavaScript is a single-threaded, non-blocking, asynchronous language, meaning it can handle multiple operations concurrently without waiting for each one to finish before moving on to the next. Asynchronous programming is crucial for handling tasks such as network requests, file I/O, and user input without blocking the main thread and causing delays in the user interface.

Callbacks:

Traditionally, asynchronous operations in JavaScript were managed using callbacks. A callback is a function that is passed as an argument to another function and is executed once the asynchronous operation completes. However, managing multiple nested callbacks can lead to callback hell, making code difficult to read and maintain.

#100daysofcode #1percentplusplus #coding #dsa


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Frequently asked questions.