Delete a last character from a string in javascript
var a = “wxyz”; a = a.substr(0, a.length – 1); console.log(a); // wxy
var a = “wxyz”; a = a.substr(0, a.length – 1); console.log(a); // wxy
Problem : Given a string find all the unique characters in the stirng. Input : A string Output : A string Logic : Iterate over entire string and create a frequency map If the...
Problem : Implement a twitter like twit-box component which limits the feed to 140 characters. Logic: If the length of the string is greater than 140 characters If the 141th character is a space...
You are given an array of strings. Each of these strings is made up of bracket characters only : ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘, ‘]’. Programming languages utilize these brackets in balanced pairs, so...
Problem : Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and...
Problem : Given two (dictionary) words as Strings, determine if they are isomorphic. Two words are called isomorphic if the letters in one word can be remapped to get the second word. Remapping a...
Reverse a given string Input : A string // ‘Hello’ Output : A string // ‘olleH’ There are many ways of reversing a string. Approach 1 : Simplest way is to use inbuilt javascript...
Input : Two strings // ‘dog’, ‘god’ ; ‘foo’,’bar’ Output : Boolean // True ; False Clarifications : Is the comparison of our string permutation case sensitive? Yes Is whitespace significant? Yes Approach 1...
Input : A string Output : Boolean Clarifications : Is the input string ASCII or Unicode ? If ASCII then we need storage size of 128 bits Logic : Iterate over entire string If...