There is a DNA Strand having values as A , T , C , G.
All combinations are present in the the file.

Write a method which takes starting mutation string , ending mutation string and string bank and calculates the minimum mutation distance required. But the condition is that either of the start or end must be present in the bank.

AATTGGCC is starting and TTTTGGCA is ending then mutation distance will be 3. …


Create a simple stack which takes a list of elements.
Each element contains a stack operator (push, pop, inc) and a value to either push/pop or two values, n and m, which increment the bottom n values by m.
Then print the topmost value of the stack after every operation. If the stack is empty, print “empty”


  • push and pop operations would be as usual.
  • Brute Force: inc(n, m) can be achieved by simply updating the the bottom n elements with m value by accessing all the elements of the stack.

Dictionary encoding is a loss-less compression technique to compress a list of words. Dictionary encoding works by maintaining a mapping of unique words to their compressed value, and replacing occurrence of the words with the compressed value

Here is an example:

Input String:

Potential Encoder Output String:

The code is assigned to the country in the order they appear in the input, starting from 0 and so on

decode(encode(input)) = input


class Solution
public static String encode(final String input) {

// Split the input string to assist encoding
String[] encoded = input.split(",");
int n = encoded.length;

A sawtooth sequence is a sequence of number that alternate between increasing and decreasing. In other words, each element is either strictly greater than it’s neighboring element or strictly less than it’s neighboring elements.

Problem Statement:

Given an array of integers arr, your task is to count the number of contiguous subarrays that represent a sawtooth sequence of at least two elements.

  • For arr = [9, 8, 7, 6, 5], the output should be countSawSubarrays(arr) = 4.

Since all the elements are arranged in decreasing order, it won’t be possible to form any sawtooth subarray of length 3 or more…

prashant kumar

Software Development Engineer Alexa AI. Sport programmer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store