Author: Kavit

Netflix 0

Closures, currying, partially applied function interview question in javascript

Write a function say which logs the following. console.log( say(‘Foo’)(‘bar’)() ) // => “Foo bar ” console.log( say(‘Hi’)(‘my’)(‘name’)(‘is’)(‘Foo’)() ) // “Hi my name is Foo ” Understanding closures, currying, partially applied functions in javascript...

0

Tic Tac Toe Winner

Interview Question Implement an algorithm that determines if someone has won a game of tic-tac-toe Algorithm To determine if any of the two players have won the TicTacToe game or not, We need to...

0

How to get the number from the middle of a string

Given the following string extract the number ‘Buy for $199.99’ // 199.99 ‘Gas Price $2.304 per gallon’ // 2.304 We can solve this using slice and, parseFloat(). slice returns the string from the starting...

0

hex to rgba conversion using javascript

Algorithm get two characters from the input string at a time and convert it to the integer For example let hex = ‘ff00ff’; let r = parseInt(hex.substring(0, 2), 16) // 255 concat all the...

0

Format the given number into an American currency format

Convert a given number into the formatted number. Logic Traverse the┬ástring in the reverse order Consider the following cases : Positive numbers, Negative numbers, Positive floating point numbers, Negative floating point numbers   Solution

0

Connect nodes at the same level in a binary tree

PSEUDO ALGORITHM (Breadth first search approach) We will use the same algorithm discussed in level-order-breadth-first-search-or-zig-zag-traversal-of-a-binary-tree with slight modification. Create an empty queue q Initialize roots height = 0; Enqueue q with the root node Loop...

Show Buttons
Hide Buttons