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


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


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


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


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