Reverse a String without Affecting Special Characters | Leet Code JavaScript Coding Challenge

preview_player
Показать описание
Please like, share and subscribe if you found the video useful.
Checkout the Playlists:
#leetcode #javascript #javascriptinterviewquestions #leetcodesolution
👉 JavaScript Tutorials:
👉 Essentials for Web developers:
👉 React Hooks & Latest concepts:
👉 HTML Tutorials:
👉 CSS Tutorials:
👉 Coding Challenges:
👉 Best Practices & Common mistakes:
👉 React js for Beginners:
👉 Things To Know As JavaScript/FrontEnd Developer:

LIKE | SHARE | SUBSCRIBE 😊

👇👇👇
Follow me on
Рекомендации по теме
Комментарии
Автор

while inserting special character into result, suppose we have index which is greater then length of result..( i mean we have only 3 character and 10 special character) Is this solution will work?

jaikaran
Автор

Hi, as someone who interviews and hires programmers, readability and elegance are at the top of my list. Thanks for the solution. It's always exciting to see how different people solve such tasks.
But it seems unnecessarily complex and a lot of code. Please do not misunderstand. If the code is more readable and comprehensible, one-liners are much worse.

What do you think about this solution:

const input = "qa45&7abc+#9812121asas";
const inputOnlyChars = input.replace(/[^a-z]/gi, '').split('');
const reversed = input.replace(/[a-z]/gi, ()=>inputOnlyChars.pop() ?? '');
console.log(reversed);

Greetings from Germany, Thomas

TjomasDE