# Category: Microsoft

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

## Level order, breadth first search or zig-zag traversal of a binary tree

Traverse the binary tree in breadth first search also known as level order traversal manner. // Should print  8, 3, 10, 1, 6, 14, 4, 7, 13 Pseudo Algorithm PSEUDO ALGORITHM (Breadth first search...

## Length of Longest Substring Without Repeating Characters

Example Given “bbb”, the answer is 1. Given “pwwke”, the answer is 3. Algorithm Time complexity: O(n) Have a pointer which tracks the starting index of the current substring Create a map of each...

Design an Email Service API service     Requirements   Who is the end consumer of the API ? Internal developers Third party developers Security Authentication Authorization Auditing Database Max storage per company based on...

## Merge K-sorted Arrays

Problem : Given k sorted arrays of size n, merge all the k arrays into one sorted array. Example : var n_k_arr = [ [ 8, 10, 12 ], [ 6, 9, 13 ],...

## Delete all the nodes from a binary tree

Recursive : To delete all the nodes, you will have to visit all the nodes. There are three ways to traverse the binary tree : Post order Pre order In order. To delete all...

## Print nodes at k level from the root in a binary tree

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”] Given a binary tree, level k, print all the nodes at level k. For example, 4, 7, 8 are at level 2.   1...

## Count Negative Numbers in a Row And Column Wise Sorted Matrix [Amazon]

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” text_text_color=”#000000″ use_border_color=”off” border_color=”#ffffff” border_style=”solid”] The given Matrix satisfies the following properties : M [ i ] [ j ] ≤ M [ i ] [ j + 1...

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