## Pascals triangle javascript code

Problem : Create a pascal’s triangle using javascript. More details about Pascal’s triangle pattern can be found here. Input: #Rows = 6 Output: Logic : Pascal’s triangle can be simulated using 2-D array While...

Skip to content
# Monthly Archive: November 2015

##
Pascals triangle javascript code

##
Flatten nested array javascript

##
Generate all permutations of a given array using backtracking

##
Justify if a string consists of valid parentheses

##
Negate a number using addition operator

##
Find a pair of elements from an array whose sum equals a given number

Problem : Create a pascal’s triangle using javascript. More details about Pascal’s triangle pattern can be found here. Input: #Rows = 6 Output: Logic : Pascal’s triangle can be simulated using 2-D array While...

Problem : Given a nested array, flatten the given array. Input : [1, 2, 3, [4, 5], [6, [7, 8]]] Output : [1, 2, 3, 4, 5, 6, 7, 8] Logic : Iterate throgh...

A permutation is a rearrangement of the elements in a list. A string/array of length n has n! permutation. Input: An array // [‘A’, ‘B’, ‘C’] Output: [‘A’, ‘B’, ‘C’] [‘A’, ‘C’, ‘B’], [‘B’,...

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 number X, flip it to -X. Time complexity : O ( X ) Logic : The negation can be implemented by adding -1, X times. Solution :

Input: An array of n integers and given a number X. Expected output: All the unique pairs of elements (a, b), whose summation is equal to X. Example <pre>Given<span class=”pl-k”>var</span> unSortedArr <span class=”pl-k”>=</span> [<span...