DEV Community

vishal.codes
vishal.codes

Posted on

2 1 1 1 1

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay