N/A Interview Questions
- 0of 0 votes
AnswersWhat are the steps of the algorithm with order O(m log (mn)) for finding k-th smallest element (or median) of 2D array [1..M] [1..N] where each row of this matrix is sorted and independent from all other rows (ascending order, distinct elements)?
- Google Q November 20, 2020 in United States| Report Duplicate | Flag | PURGE
N/A IIT Exam Algorithm - 0of 0 votes
AnswersImplement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?
My version of code is this,static boolean giveresult(String s) { boolean answer=true; for(int i=0;i<s.length();i++) { char x = s.charAt(i); if(s.substring(i+1).contains(x+"")) {answer=false; break; } } return answer; }
Can I know what would be the time complexity.?
- studentharsha July 05, 2017 in United States| Report Duplicate | Flag | PURGE
N/A None - 0of 0 votes
AnswerImplement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?
- studentharsha July 05, 2017 in United States
My version of code is this,
static boolean giveresult(String s)
{
boolean answer=true;
for(int i=0;i<s.length();i++)
{
char x = s.charAt(i);
if(s.substring(i+1).contains(x+""))
{answer=false;
break;
}
}
return answer;
}
Can I know what would be the time complexity.?| Report Duplicate | Flag | PURGE
N/A None - 0of 0 votes
AnswersCreate a RESTful microservice that implements a card shuffling algorithm, as defined below. Should have evidence of test-driven development with unit tests. Use best practices of interfaces and generics for abstraction, preferably implementing a strategy pattern for deploy-time dependency injection of a shuffling algorithm.
- dbs.tkg December 11, 2016 in United States
Requirements:
· Create a microservice that stores and shuffles card decks.
· A card may be represented as a simple string such as “5-heart”, or “K-spade”.
· A deck is an ordered list of 52 standard playing cards.
· Expose a RESTful interface that allows a user to:
· PUT an idempotent request for the creation of a new named deck. New decks are created in some initial sorted order.
· POST a request to shuffle an existing named deck.
· GET a list of the current decks persisted in the service.
· GET a named deck in its current sorted/shuffled order.
· DELETE a named deck.
· Design your own data and API structure(s) for the deck.
· Persist the decks in-memory only, but stub the persistence layer such that it can be later upgraded to a durable datastore.
· Implement a simple shuffling algorithm that simply randomizes the deck in-place.
· Implement a more complex algorithm that simulates hand-shuffling, i.e. splitting the deck in half and interleaving the two halves, repeating the process multiple times.
· Allow switching the algorithms at deploy-time only via configuration.| Report Duplicate | Flag | PURGE
N/A Senior Software Development Engineer Java Object Oriented Design - 1of 1 vote
AnswersMagical binary strings are non-empty binary strings if the following two conditions are true:
- zandu November 01, 2016 in India
The number of 0's is equal to the number of 1's.
For every prefix of the binary string, the number of 1's should not be less than the number of 0's.
A magical string can contain multiple magical substrings. If two consecutive substrings are magical, then we can swap the substrings as long as the resulting string is still a magical string. Given a magical binary string, str, perform zero or more swap operations on its consecutive magical substrings such that the resulting string is aslexicographically large as possible. Two substrings are considered to be consecutive if the last character of the first substring occurs exactly one index before the first character of the second substring.
-----
Input Format
a single binary string, str.
Constraints
It is guaranteed that str is a binary string of 1's and 0's only.
1 ≤ length(str) ≤ 50
It is guaranteed that str is a magical string.
Output Format
Find a string denoting the lexicographically largest magical string that can be formed from str.
Sample Input 0
11011000
Sample output
11100100
Explanation of sample
Given the magical string str = 11011000, we can choose two consecutive magical substrings, 1100 and 10, to swap such that the resultant string, str' = 11100100, is the lexicographically largest possible magical string possible. Thus, we return the value of str', which is 11100100, as our answer.
.| Report Duplicate | Flag | PURGE
N/A Software Engineer Algorithm - 0of 0 votes
AnswersWrite a program which will get the top 'x' tweets based on their re-tweet count from 'n' tweets.
- danny459 September 20, 2016 in India| Report Duplicate | Flag | PURGE
N/A Front-end Software Engineer Algorithm - 0of 0 votes
AnswersWrite a function that will operate on a C-string and convert all instances of "AB" to "C" without using a second string for temporary storage. Use the following function signature:
- bradpitt119 December 15, 2015 in United States
void translate(char *str)
So for example:
char astring[] = "helloABworld";
translate(astring);
// Now astring holds "helloCworld";
Your function should handle strings of arbitrary length.| Report Duplicate | Flag | PURGE
N/A xyz C - -3of 3 votes
AnswersWhat does Innoplexus ask about in the personal interview round for Technical Summer Interns?
- novicedhunnu March 27, 2015 in India| Report Duplicate | Flag | PURGE
N/A Intern - 0of 0 votes
AnswersWrite a program to modify the string in following pattern,
- qe.expert March 18, 2015 in India
Change odd words to uppercase and Reverse the even words. Make sure that the spaces (multiple) between the words remains as it is.
E.g.:
Input : "This is a test String!!"
Output: "THIS si A tset STRING!!"| Report Duplicate | Flag | PURGE
N/A Software Engineer in Test Coding - -5of 5 votes
AnswersHaving A List of int [1,1,1,3,1,2,1,1,4,1]
- NullVoid December 31, 2014 in India for ERP
Output needed [1,5,6,3,7,2,8,9,4,10]
Note: Need not to change value of 3,2,4| Report Duplicate | Flag | PURGE
N/A Software Engineer / Developer Arrays Java Linked Lists - 2of 2 votes
AnswersGiven a set of entries, each containing a time index and a int count value,
- FrickenHamster September 26, 2014 in United States
ie
class Entry
{
time:int
count:int
}
write a function that will give the time interval with the highest count together,
ie,
if we had entries
100, 2
100, 1
110, 10
200, 4
1000, 3
1200, 8
and we ran something like
int highestInterval(int interval_range)
highestInterval( 50 )
it would return 100, because in 100-150, you have counts 2, 1, and 10.
I managed to get a O(n^2) solution for it, but I think theres a better solution. I think it might have to do with some preprocessing of the interval buckets, but I can't figure out the solution.| Report Duplicate | Flag | PURGE
N/A Software Engineer / Developer Algorithm