## Software Engineer / Developer Interview Questions

- 0of 0 votes
We have two strings A and B with the same super set of characters. We need to change these strings to obtain two equal strings. In each move we can perform one of the following operations:

1. swap two consecutive characters of a string

2. swap the first and the last characters of a string

A move can be performed on either string.

What is the minimum number of moves that we need in order to obtain two equal strings?

- 1of 1 vote
given n > 0 fair dice with m > 0 "sides", write an function that returns a histogram of the frequency of the result of dice rolls. For example, for two dice, each with three sides, the results are:

(1, 1) -> 2

(1, 2) -> 3

(1, 3) -> 4

(2, 1) -> 3

(2, 2) -> 4

(2, 3) -> 5

(3, 1) -> 4

(3, 2) -> 5

(3, 3) -> 6

And the function should return:

2: 1

3: 2

4: 3

5: 2

6: 1

- 0of 0 votes
Given n rows of integers, such that the ith row (1 <= i <= n) contains i integers, find the path having the maximum weight.

Path traversal rules:

1. A valid path sequence would be top-down i.e. begins with the integer in the first row, and traverses all rows selecting only one integer in each row.

2. From any jth integer in the ith row i.e row[i][j], traversal can happen either downward (i.e to row[i+1][j]) or diagonally downward to the right (i.e to row[i+1][j+1])

The weight of a Path is the sum of values of integers in the Path sequence.

Sample Input:

No. of Rows: 5

4

2 9

15 1 3

16 92 41 44

8 142 6 4 8

Expected Output: 4, 2, 15, 92, 142 (Max weight is 255)

- 0of 0 votes
Given two integer arrays. Find the Largest Common sub array. For example,

arr1 = {1,2,3,2,3,2} arr2={2,2,3,3,4,5}, the largest common sub array is {2,2,3,3}

- 2of 2 votes
`int fun() { /*write code here.*/ } int main() { int i=10; fun(); printf("%d",i); }`

change the value of the i without changing code of the main function, assign 20 to i ?

- 0of 0 votes
Given ~300k words with an average length of 7 in a file.

All words are dictionary correct words.

Print all the anagrams that are present in this list of words without repeating them.

E.g. if the list has:

ACT

BAT

CAT

TAB

TAC

print:

ACT, CAT, TAC

BAT, TAB

- 0of 0 votes
Design the algorithm and the system for a WebCrawler.

The webcralwler will be provided millions of URLs. The webpage will be downloaded and then parsed for more URLs. If more URLs are found then they should also be downloaded and parsed.

He was interested in:

1. Scale to handle millions of URLs

2. What are the bottle necks in the system? How will you resolve them

- 0of 0 votes
Design a vending machine

- 0of 0 votes
Given a sorted array with some sequenced numbers and some non-sequenced numbers. Write an algorithm that takes this array as an input and returns a list of {start, end} of all consecutive numbers. Consecutive numbers have difference of 1 only.

E.g. of array:

[4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 20, 22, 23, 24, 27]`public class Range { private int begin; private int end; public int begin { get; set; } public int end { get; set; } }`

- 0of 0 votes
1. Consider an ordinary binary min- heap data structure with n elements supporting the instructions INSERT and EXTRACT-MIN in O(lg n) worst case time. Give a potential function f such that the amortized cost of INSERT is O(lg n) and the amortized cost of EXTRACT-MIN is O(1) , and show that it works.

- 1of 1 vote
Implementing Deque using 3 Stacks (Amortized time O(1)) , I can't solve this problem ???

Amortized time O(1) what is Amortized time O(1)) ????

- 0of 0 votes
There are two coins that make 55 cents. If one of them is not nickle then what are the two coins?

- 0of 0 votes
A bear have to climb a 60.5 feet long hill. It climbs 3 feet in every minute before it fall down for 2 feet. How long it will take to climb the hill?

- 0of 0 votes
Colorful Number:

A number can be broken into different sub-sequence parts. Suppose, a number 3245 can be broken into parts like 3 2 4 5 32 24 45 324 245. And this number is a colorful number, since product of every digit of a sub-sequence are different. That is, 3 2 4 5 (3*2)=6 (2*4)=8 (4*5)=20 (3*2*4)= 24 (2*4*5)= 40

But 326 is not a colorful number as it generates 3 2 6 (3*2)=6 (2*6)=12.

You have to write a function that tells if the given number is a colorful number or not.

- 0of 0 votes
A string "aBIY" is said to be a well-ordered word as each of the letters are in sequential manner regardless of case. So, "AbLe" is not a well-ordered word.

You are a anti-hacker. you have a number of character sequences. Your task is to generate all possible well-ordered word that can be generated by those numbers of given character sequences.

- 0of 0 votes
Edge Detection:

Two-dimensional array representation of an image can also be represented by a one-dimensional array of W*H size, where W represent row and H represent column size and each cell represent pixel value of that image. you are also given a threshold X. For edge detection, you have to compute difference of a pixel value with each of it's adjacent pixel and find maximum of all differences. And finally compare if that maximum difference is greater than threshold X. if so, then that pixel is a edge pixel and have to display it.

- 1of 1 vote
Use the shorest unique prefix to represent each word in the array

input: ["zebra", "dog", "duck",”dot”]

output: {zebra: z, dog: do, duck: du}

[zebra, dog, duck, dove]

{zebra:z, dog: dog, duck: du, dove: dov}

[bearcat, bear]

{bearcat: bearc, bear: ""}

- 0of 0 votes
Given an array of paper products in which each product has an attribute name, width, and height, and given a sheet of paper that has width xx and height yy, write a program that returns the number of sheets of paper needed to print out the array of paper products

- 2of 2 votes
Print combinations of strings from List of List of String

Example input: [[quick, slow], [brown, red], [fox, dog]]

Output:

quick brown fox

quick brown dog

quick red fox

quick red dog

slow brown fox

slow brown dog

slow red fox

slow red dog

- 0of 0 votes
Write a function that takes a list of positive integers as an input, and returns all of the pairs of integers it contains that sum to 100. You can assume that all inputs are between 1 and 99.

- 0of 0 votes
This test was on https://www.hackerrank.com

Input is a string of Bytes E.g.341B

Convert it to human readable form: 3 characters long (excluding decimal)

No trailing or leading zeros

E.g:

Input 341B

Output 341B

Input 12345B

Output 12.3K

Input 1234567B

Output 1.23M

Input 1000000000B

Output 1G

Do not round off

Assume input will not be more than 1G

For this problem 1000B = 1K, so on and so forth

- 0of 0 votes
We are given a specific time(like 02:23), we need to get the angle between hour and minute(less than 180)

- -2of 2 votes
Given an array of numbers print the values in diagonal format.

Example (1) for 8 dataset

Input Array : [1, 2, 3,4,5,6,7,8]

Output

01 02 04 07

03 05 08

06

Example (2) for 45 dataset

Input Array: [1, 2, 3,4,5,6,7,8,9,10……….44, 45]

Output

01 02 04 07 11 15 19 23 27 31 35 39

03 05 08 12 16 20 24 28 32 36 40 43

06 09 13 17 21 25 29 33 37 41 44

10 14 18 22 26 30 34 38 42 45

Code in Java.

- 1of 1 vote
Given number of digits of a phone number and number of disallowed digits as input, find all permutations of numbers which do not have two adjacent numbers the same, i.e. 1232 is allowed but not 1223. Disallowed digits can be upto 3, and can be included along with the phone number. Also the phone number should start with 4 if it contains the number 4.

- 0of 0 votes
The decimal and octal values of some numbers are both palindromes sometimes. Find such numbers within a given range.

- 0of 0 votes
If one and a half teenagers, eat one and a half pizzas in one and a half days, how many pizzas can 9 teenagers eat in 3 days

- 0of 0 votes
Suppose I am given a set of input strings input[5](five of them) and their corresponding replacement strings replace[5]. Then I am given an input text, how can I replace the strings in the text matching any of the inputs with their corresponding replacements.

Also I have to make sure that if suppose, I find a match input[0] and I replace it by replace[0], then because of that it could be possible that I have a new match for input[2] lets say because of the new characters added by replace[0]. I don't want to make replacements with replace[2].

- 0of 0 votes
Suppose I have five strings input[5] and their corresponding replacements replace[5]. I am given an input text and I want to find the occurence of any of the input strings and replace them with the corresponding replace strings. I cannot use regex. How can I do it. Also I have to make sure that lets say after replace input[0] with replace[0], if a new string arises due to replace[0] that matches with lest say input[2], then I cannot replace it with replace[2].

- 0of 0 votes
Goldbach's conjecture : Every even integer greater than 2 can be expressed as the sum of two primes.

Write a function which takes a number as input, verify if is an even number greater than 2 and also print atleast one pair of prime numbers.

- 2of 2 votes
The stepping number:

A number is called as a stepping number if the adjacent digits are having a difference of 1. For eg. 8,343,545 are stepping numbers. While 890, 098 are not. The difference between a ‘9’ and ‘0’ should not be considered as 1.

Given start number(s) and an end number(e) your function should list out all the stepping numbers in the range including both the numbers s & e.