## Front-end Software Engineer Interview Questions

- 0of 0 votes
Given a Binary string of 0s and 1s, and k, Find the number of different ways to get longest continuous streak of 1s. You can flip any k number of 0s to 1s.

Example:

1)Stirng is S=1010101, K=1

Result=3

1)Stirng is S=01010, K=3

Result=1

- 0of 0 votes
Write a program which will get the top 'x' tweets based on their re-tweet count from 'n' tweets.

- 0of 0 votes
What are semantic tags in HTML?

- 0of 0 votes
What are services in Angular.js?

- 0of 0 votes
What is difference between Ember and Angular.js?

- 0of 0 votes
What are inline elements? What are block elements in HTML?

- 0of 0 votes
What is Dependency Injection in Angular.js?

- 3of 3 votes
We have an array of objects A and an array of indexes B. Reorder objects in array A with given indexes in array B. Do not change array A's length.

example:`var A = [C, D, E, F, G]; var B = [3, 0, 4, 1, 2]; sort(A, B); // A is now [D, F, G, C, E];`

- 0of 0 votes
you are on a biz trip and travelling from one city to another. you have a stack of unsorted flight boarding passes. only departure city and destination city are on the boarding pass. how do you find the first departure city and your final destination city, write the solution in javascript.

- 0of 0 votes
Write a function to determine if a string is a number without using any built-in function.

`public bool IsNumber(string num) { }`

- 0of 0 votes
Steps Problem,

Givin n, find how many different ways you can take steps to reach the top

E.g.

findSteps(4)

1,1,1,1

1,1,2,

2,2

1,3,

4

this would return 5

- 0of 0 votes
Count Scorecards

In a tournament, N players play against each other exactly once. Each game results in exactly one player winning. There are no ties. You have been given a scorecard containing the scores of each player at the end of the tournament. The score of a player is the total number of games the player won in the tournament. However, the scores of some players might have been erased from the scorecard. How many possible scorecards are consistent with the input scorecard?

Input Format

The first line contains the number of cases T. T cases follow. Each case contains the number N on the first line followed by N numbers on the second line. The ith number denotes s_i, the score of the ith player. If the score of the ith player has been erased, it is represented by -1.

Output Format

Output T lines, containing the answer for each case. Output each result modulo 1000000007.

Constraints:

1 <= T <= 20

1 <= N <= 40

-1 <= s_i < N

Sample Input:

5

3

-1 -1 2

3

-1 -1 -1

4

0 1 2 3

2

1 1

4

-1 -1 -1 2

Sample Output:

2

7

1

0

12

Explanation:

For the first case, there are 2 scorecards possible: {0,1,2} or {1,0,2}.

For the second case, the valid scorecards are {1,1,1}, {0,1,2}, {0,2,1}, {1,0,2}, {1,2,0}, {2,0,1}, {2,1,0}.

For the third case, the only valid scorecard is {0,1,2,3}.

For the fourth case, there is no valid scorecard. It is not possible for both players to have score 1.

For the fifth case, 6-variations of {{3,1,0}[2]}, 3 variations each of {{2,2,0}[2]} and {{2,1,1}[2]}

Max Score: 89pts dynamic

Suggest Edits

- 0of 0 votes
For a table created using the following commands. State the SQL SELECT command to find the 1st and 2nd highest salary earned by staff working in DEL or MUM

CREATE TABLE Employees (

ID int NOT NULL AUTO_INCREMENT,

Name varchar(100),

Sal decimal (10,2),

City char (3),

PRIMARY KEY (ID)

);

INSERT INTO Employees (Name, Sal, City) VALUES ('Ramesh',20000, 'BLR');

INSERT INTO Employees (Name, Sal, City) VALUES ('Sunil',24000, 'DEL');

INSERT INTO Employees (Name, Sal, City) VALUES ('Sreeja',21000, 'MUM');

INSERT INTO Employees (Name, Sal, City) VALUES ('Pavan',23000, 'DEL');

INSERT INTO Employees (Name, Sal, City) VALUES ('Maya',24000, 'MUM');

- -1of 1 vote
The below Java program prints the numbers from 1 to 50. But for multiples of three print "DNA" instead of the number and for the multiples of five print "RNA". For numbers which are multiples of both three and five print "ATGC". Please identify the three bugs in the code and suggest how they can be resolved.

public class SeqTest {

public static void main(String args[]) {

for(int i = 1; i <= 50; i++) {

if(i % 3 == 0) System.out.println("DNA");

else if(i % 5 == 0) System.out.println("RNA");

else if(i % (3+5) == 0) System.out.println("ATGC");

else System.out.println(“1 to 50”);

}

}

}

- 1of 3 votes
You have a dictionary which is an array of words and array of strings.

Write two functions

1. Prepare the array of strings to be searched in the dictionary

2. Check if the string contains all valid words or not.

- 3of 3 votes
Here is a good puzzle:

How do you write a program which produces its own source code as output?

- -1of 3 votes
Given a string Sting="ABCSC" Check whether it contains a Substring="ABC"?

1)If no , return "-1".

2)If yes , remove the substring from string and return "SC".

use very simple code and concept(ALGORITHM)..

- 0of 2 votes
Delete a specific char from string,,,,char is 'f' in string= "YOUSUF".the resultant string will be "YOUSU".

- 0of 2 votes
A string str ="STUN",, u hav to replace TU by KO . The resultant String "SKON". Use simple logic...

- -1of 1 vote
str="AB0CD1010" this s a string consider it as a counter variable n increment it

for example the next element should be "AB0CD1011"

Note: If anyone know the answer fr ths ques well,pls post with full code and ALGORITHM(for beginners)...

- -1of 1 vote
Add the diagonal elements of a square matrix (of odd order say 3*3,5*5) but the intersecting element must be added only once.

Sorry for my poor english..That what i understood from interviewer..

- 2of 4 votes
Alex is standing on the top left cell (1,1) of a n*m table. The table has n rows and m columns. Initially, he is facing its right cell. He moves on the table in the following way:

>He moves one step forward.

>He turns to his right

>While moving forward, if he would go out of the table or reach a visited cell, he turns to his right.

He moves in the table as much as he can. Can you find out the number of cells he visits before he stops?

For example, given a 9x9 grid, the following would be his moves. The number on each cell represents the step he would land on that particular cell.

1 2 55 54 51 50 47 46 45

4 3 56 53 52 49 48 43 44

5 6 57 58 79 78 77 42 41

8 7 60 59 80 75 76 39 40

9 10 61 62 81 74 73 38 37

12 11 64 63 68 69 72 35 36

13 14 65 66 67 70 71 34 33

16 15 20 21 24 25 28 29 32

17 18 19 22 23 26 27 30 31

Input:

The first line of the input contains two integer numbers n and m.

n and m are between 1 and 100.

Output:

Print an integer to the output being the answer of the test.

Sample input #00:

3 3

Sample output #00:

9

Sample input #01:

7 4

Sample output #01:

18

- 1of 3 votes
We have a rectangle with n rows and m columns filled with numbers from 1 to n*m.

Cell (i,j) of the rectangle is important iff:

* i = 1 and j = 1 (or)

*there is an important cell (a,b) such that (a,b) is a neighbor of (i,j) and the number

on (i,j) is greater than number on cell (a,b) and all of (a,b)'s neighbors except for (

(i,j) itself

Two cells are considered to be neighbors if they share a common edge between them.

Unfortunately the number in some of the cells has been erased. We want to write a number to those cells such that the resultant rectangle has all the numbers between 1 to n*m and it contains as many important cells as possible. In case there are several ways to do that, we are interested with the rectangle which is lexicographically smallest.

A table is lexicographically smaller that the other if the string of its row-major view is lexicographically smaller than the other.

Input:

The first line of the input contains two integers n and m, Each of the next n lines contains m tokens. Each token is either an integer between 1 and n*m or '?'.

Output:

Print the maximum number of important cells that can be obtained in the first line of the output and print the rectangle in the next n lines.

Constraints:

1 <=n,m <=6

Sample input #00:

2 3

2 ? ?

? ? 3

Sample output #00:

3

2 1 4

5 6 3

Sample input #01:

6 6

? ? ? ? ? ?

? ? ? ? ? ?

? ? ? ? ? ?

? ? ? ? ? ?

? ? ? ? ? ?

? ? ? ? ? ?

Sample output #02:

24

1 2 3 13 14 15

4 6 8 10 11 16

5 7 9 12 19 17

28 26 24 22 20 18

29 27 25 23 21 36

30 31 32 33 34 35

- 3of 5 votes
A string is called sstring if it consists of lowercase english letters and no two of its consecutive characters are the same.

You are given string s of length n. Calculate the number of sstrings of length that are not lexicographically greater than s.

Input format

The only line of input contains the string s. It's length is not greater than 100.

All characters of input are lowercase english letters.

Output format:

Print the answer of test modulo 1009 to the only line of output.

Sample input:

bcd

Sample output:

653

- 0of 0 votes
Given an array A of length n where each element is 1..k where k is much smaller than n,

find one set of distinct indices i1 and i2 such that A[i1] + A[i2] == z.

- 0of 4 votes
Below question was asked in online coding exam for Palantir Technology, Palo Alto, CA. Time given was 100 min. I could not complete it by the time.

-----------------------------

A group of farmers has some elevation data, and we’re going to help them understand how rainfall flows over their farmland.

We’ll represent the land as a two-dimensional array of altitudes and use the following model, based on the idea that water flows downhill:

If a cell’s four neighboring cells all have higher altitudes, we call this cell a sink; water collects in sinks.

Otherwise, water will flow to the neighboring cell with the lowest altitude. If a cell is not a sink, you may assume it has a unique lowest neighbor and that this neighbor will be lower than the cell.

Cells that drain into the same sink – directly or indirectly – are said to be part of the same basin.

Your challenge is to partition the map into basins. In particular, given a map of elevations, your code should partition the map into basins and output the sizes of the basins, in descending order.

Assume the elevation maps are square. Input will begin with a line with one integer, S, the height (and width) of the map. The next S lines will each contain a row of the map, each with S integers – the elevations of the S cells in the row. Some farmers have small land plots such as the examples below, while some have larger plots. However, in no case will a farmer have a plot of land larger than S = 5000.

Your code should output a space-separated list of the basin sizes, in descending order. (Trailing spaces are ignored.)

While correctness and performance are the most important parts of this problem, a human will be reading your solution, so please make an effort to submit clean, readable code. In particular, do not write code as if you were solving a problem for a competition.

A few examples are below.

Input:

3

1 5 2

2 4 7

3 6 9

Output:

7 2

The basins, labeled with A’s and B’s, are:

A A B

A A B

A A A

Input:

1

10

Output:

1

There is only one basin in this case.

Input:

5

1 0 2 5 8

2 3 4 7 9

3 5 7 8 9

1 2 5 4 2

3 3 5 2 1

Output:

11 7 7

The basins, labeled with A’s, B’s, and C’s, are:

A A A A A

A A A A A

B B A C C

B B B C C

B B C C C

Input:

4

0 2 1 3

2 1 0 4

3 3 3 3

5 5 2 1

Output:

7 5 4

The basins, labeled with A’s, B’s, and C’s, are:

A A B B

A B B B

A B B C

A C C C

- 0of 0 votes
How would you build a stock ticker service?

- 0of 0 votes
Assuming a preexisting list of 100 words, how would you efficiently see if a word received from input is an anagram of any of the 100 words?

- 0of 0 votes
What are some ways of improving performance of the web pages using HTML, JS and CSS optimization?

- 0of 0 votes
Extend the JavaScript Array object by adding a method that removes duplicates.