Maximum Flips in a Binary String to Make All 1’s in Left and All 0’s in Right

Given a binary string, we can flip all 1s and 0s . Calculate the minimum flips required to make all 1s in left and all 0s in right. There should be at least one 0 and one 1. Examples: "1011000" can ...
Berkan Teber
Published on Jan 16th, 2018

Find All Possible Interpretations

Consider a coding system for alphabets to integers where ‘a’, ‘b’, ..., ‘z’ are represented as 1, 2, ..., 26. Given a string of digits 1..9 as input, write a function that prints all valid interpre ...
Berkan Teber
Published on Jan 16th, 2018

Largest Sum Subarray with At Least k Numbers

Given an array, find the subarray (containing at least k numbers) which has the largest sum. Return the sum. Examples: [-4, -2, 1, -3] and k = 2 should return -1. The subarray is [-2, 1]. [1, 1, 1 ...
Berkan Teber
Published on Jan 16th, 2018

Decode String Recursively

An encoded string is given. The pattern in which the strings are encoded is as follows: [substr] means that the substring 'substr' appears count times. The task is to decode the given string. Exampl ...
Berkan Teber
Published on Jan 16th, 2018

Find the Maximum Value by Inserting ‘+’, ’*’ and '()'

Given an array of numbers, the task is to find the maximum value from the string, you can add a ‘+’ or ‘*’ sign between any two numbers. You should also use parantheses. Examples: [0, 1, 2, 3, 1] c ...
Berkan Teber
Published on Jan 16th, 2018

Maximum Path with the Same Labels

Consider an undirected tree with N nodes, numbered 1..N. Each node has a label associated with it, which is an integer value. Different nodes can have the same label. You are given a zero indexed arr ...
Berkan Teber
Published on Jan 15th, 2018

Minimum Number of Multiplication in Matrix Multiplication

Given the dimensions of n matrices M1..Mn, what is the minimum number of multiplication in M1 x M2 x ... x Mn. Example: Suppose dimensions are given as [10, 30, 5, 60], meaning 3 matrices with dime ...
Berkan Teber
Published on Jan 15th, 2018

Find Longest Substring with k Unique Characters

Given a string you need to print longest possible substring that has exactly k unique characters. If there are more than one substring of longest possible length, return the lexicographically largest ...
Berkan Teber
Published on Jan 15th, 2018

Minimum Number of Swaps Required to Arrange Pairs Adjacent to Each Other

There are n pairs and therefore 2n people. Everyone has one unique number ranging in 1..2n. All these 2n persons are arranged in random fashion in an array of size 2n. We are also given who is partne ...
Berkan Teber
Published on Jan 15th, 2018

Sum of Bit Differences Among All Pairs

Given an integer array of n integers, find sum of bit differences in all pairs that can be formed from array elements. Bit difference of a pair (x, y) is count of different bits at same positions in ...
Berkan Teber
Published on Jan 15th, 2018