All Questions
Tagged with array interview-questions
50 questions
2
votes
2
answers
112
views
Print Binary coded decimal Numbering of a given input number
Example 1
input:3
output:0011
Example 2
input : 15
output: 1111
in the below example code 15 is input.
I have taken 8 4 2 1 as array for Binary coded decimal numbering
this code is working as ...
3
votes
3
answers
1k
views
Printing rotations of an array 7 times
Loop through a given array 7 times and print the following output:
int[] arr = { 9, 2, 7, 4, 6, 1, 3 };
...
2
votes
0
answers
105
views
Create array given number of larger elements to right of each member
I want to improve on my original solution to this problem,
my solution is O(n^2) and I think it's possible to solve in less time
You have two arrays: A and B. A contains ints and B has pairs: (...
10
votes
4
answers
865
views
Product of all but one number in a sequence
I was given the following prompt in a coding interview:
Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the ...
5
votes
2
answers
266
views
c# Efficient solution: Sequence generator for a pattern
This is an interview question to generate the below pattern of numbers in a sequence, which is: 12.34, 23.45, 45.67, 78.910, 1112.1314, 1617.1819, 2223.2425, 2930.3132, 3738.3940, 4647.4849, 5657.5859,...
1
vote
2
answers
852
views
Merge two sorted arrays that can be of different sizes
I think the algorithm implementation itself is reasonably efficient, but I'm not sure about proper use of good practices in software development in the code (variable naming, idioms, comments, error ...
2
votes
1
answer
114
views
Propagation in grid
Can I do it with a lower Big O / better code? How can I improve this solution?
Task:
Let's assume we have a array like this:
1 0 0 1 0
0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
1 0 0 0 0
...
4
votes
1
answer
3k
views
Find number of horizontal brush strokes to paint a skyline
Asked in interview today:
You want to paint a skyline on your wall using only horizontal brush strokes. You are given an array of numbers, each representing the size of the column/building in that ...
6
votes
3
answers
370
views
Leetcode - First Unique Character in a String
Given a string, find the first non-repeating character in it and
return its index. If it doesn't exist, return -1.
Examples:
...
2
votes
1
answer
723
views
Leetcode - product of array except self
Given an array nums of n integers where n > 1, return an array output
such that output[i] is equal to the product of all the elements of
nums except nums[i].
Example:
...
2
votes
1
answer
2k
views
Rotate matrix 90 degrees
I recently did problem 1.7 Rotate Matrix in Cracking the Coding Interview. I realized my code is very different than what is in the book and also from what I'm finding online (I'm having trouble ...
4
votes
2
answers
450
views
Replace array element with multiplication of neighbors in Scala
Given an array of integers, update the index with multiplication of previous and next integers,
Input: 2 , 3, 4, 5, 6
Output: 2*3, 2*4, 3*5, 4*6, 5*6
Following ...
4
votes
1
answer
929
views
Longest Substring Without Repeating Characters in Scala
Question is taken from Leetcode and solution works for their test cases. I do see a scope of improvement and make it more functional (getting rid of vars and mutables data structures). Please suggest ...
1
vote
1
answer
99
views
Check if list contains a pair which adds up to a given sum
Kindly review this scala code for given problem and suggest improvements.
Problem - Given an array of integers and a target sum, check if array contains a pair which adds up to sum.
Example -
<...
1
vote
1
answer
64
views
Find the combination of matches which are closest to each other
Problem - Given three sorted arrays find combinations which are closest to each other.
example -
...