# Tagged: strings

## Delete a last character from a string in javascript

var a = “wxyz”; a = a.substr(0, a.length – 1); console.log(a); // wxy

## Algorithm: find unique characters in a string using javascript

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...

## Implement twit box word limiting feature

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...

## Replace all spaces in a string with %20

The solution is self explanatory. Solution :

## Justify if a string consists of valid parentheses

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...

## Determine given a pattern and string are isomorphic

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...

## Determine if given strings are isomorphic

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, also using similar technique reverse a sentence without reversing words

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...

## Determine if given strings are anagram.

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...

## Determine if a string has all unique characters

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...