The basics | Inbuilt Function of Js
How to declare a String in JS
Accessing Characters
Accessing Characters
Looping a string
Modifying Strings
Concat & Trim (Trim has only removed side spaces | didn't remove space in between )
Searching in String
Took a part from a string ( Slice, Subdtring)
Convert Case ( Str -> number | Num -> Str | etc..)
This is important because if we Typecast an Object in Js it gives a [ Object Object ] simple mines gives us its type
Convert a String
Check Ascii value or Convert to Ascii Value
String Compare
it returns 0 if it is the same otherwise -1
To check whether something is included in String or not
It returns True | False values
Splitting and Joining Strings
It breaks the string from " " (space) occurs
Finally The Main Data Structure & Algorithm Questions Start.
My Solution:
`const mainString = ' Hay Good Morning Brother';
const maxLenght = 10;
if (mainString.length >= maxLenght) {
let trimedvalue = mainString.trim();
let finalVersionOfString = trimedvalue.replaceAll(" ", "");
console.log(${finalVersionOfString.slice(0, 10)}...
);
} else {
console.log(mainString);
}
// Output : HayGoodMor...`
Piyush's Solution:
Q2: Plaindrome:
My Solution:
I add comments with ChatGPT (I think it is a better approach because sometimes interviewers don't allow to use inbuilt functions of a language )
quick Question
Can Someone Explain?
Hey, I tried my best and approached this question in five different ways using JavaScript. The average runtime is around 140ms. However, when I attempted the same question in Java, it only took around 9ms. How is this possible? Why is there such a significant difference? Could someone please explain?
Question 03: 461. Hamming Distance
A quick tip: Convert a number to binary just | let num = 10; num.toString(2) --> that 2 refers base^2
I don't know why on leetcode in this program time limit exceeds.
Here is the optimized Solution.
Question 04: 242. Valid Anagram
Solution: (UnOptimized ) Easy one:
Solution: (Optimized ):
Bonus:
Top 10 most asked frontend interview questions from string
Reverse a String
Check Palindrome
String Anagrams
Longest Substring Without Repeating Characters
String Compression
Implement strStr()
Valid Parentheses
Longest Common Prefix
Group Anagrams
Count and Say
Top comments (0)