Amdocs Interview Questions
- 0of 0 votes
AnswersYou have a non empty binary array with value 0 and 1. You can flip either 0 or 1 bit of array to make the consecutive element same.You have to return the count of consecutive number with same digit.
Input : [ 1,0,1,0,0,0]
Output : 4
if you flip the value of 1st index to 1, you have 2 consecutive 1 and 2 consecutive 0 so total 4.
input : [0,0,0,0]
output : 3
input : [0]
output 1
there is bug in below code which i couldn't find it.
- sandeepmnit35 January 09, 2018 in Indiaclass Solution { int solution(int[] A) { int n = A.length; int result = 0; for (int i = 0; i < n - 1; i++) { if (A[i] == A[i + 1]) result = result + 1; } int r = 0; for (int i = 0; i < n; i++) { int count = 0; if (i > 0) { if (A[i - 1] != A[i]) count = count + 1; else count = count - 1; } if (i < n - 1) { if (A[i + 1] != A[i]) count = count + 1; else count = count - 1; } r = Math.max(r, count); } return result + r; } }
| Report Duplicate | Flag | PURGE
Amdocs Android Engineer Arrays - 1of 1 vote
AnswersSingleton(write a singleton class , and when we use singleton ) , design pattern , serialize , implement with existing code : Comparable(compareTo()) , hashCode() , equals , synchronize . what is SWING ? , what is WebStart ?
- pointer.ptr February 20, 2015 in United States for Java| Report Duplicate | Flag | PURGE
Amdocs Software Engineer - 0of 0 votes
Answer* input :
- pointer.ptr February 20, 2015 in United States for Java
point (x,y) - assume that the point exist into the shape
isBounded(x,y) : return 1 if the point (x,y) is out of shape , and return 0 if the point (x,y) is into shape
task : to write a code\pseudo code to print a shape with input| Report Duplicate | Flag | PURGE
Amdocs Software Engineer - 0of 0 votes
AnswerDefine the following classes
- ruhi July 30, 2014 in United States
- Book which has the fields title(String), author (String), count (int). Also define the following function in the class
increment() : increases count by 1.
decrement() : reduces the count by 1. If count is 0, it remains 0.
- Library which has a field books (of type Book[]). It also has the following functions
getCount(String title) : given the title of a book as parameter, return how many copies of the book are there in the library
getCount(Book book) : given the object of type Book as parameter, return how many copies are there of that book in the library
getCount() : returns the total number of books in the library
getDiffCount() : returns the number of different books in the library
addBook(Book book) : given an object of type Book as input, increment its count if it is in the library else adds the book.
removeBook(Book book) : given an object of type Book as input, decreases the count of that book if it exists in the library. If the count becomes 0, it is removed.| Report Duplicate | Flag | PURGE
Amdocs - 0of 0 votes
AnswersDefine a class Passenger having the fields name (String), age (int), gender (char : M/F), weight (int). Define 2 constructors for this class, one with parameters and one which has no parameters.
- ruhi July 30, 2014 in United States
Also define a class Train in which there are the following functions. Note that there are no fields in the class Train.
- int getTotalWeight(Passenger[] passengers) - returns the total weight of all the passengers in the input
- int countChildren(Passenger[] passengers) - returns the number of children in the input passengers. A child is defined as age 12 or below
- int countGender(Passenger[] passengers, boolean male) - returns the number of males if true else returns the number of females. A male has the gender 'M' and a female 'F'
- Passenger[] addPassenger(Passenger[] passengers, Passenger passenger1) - returns a Passenger[] which contains all the passengers and also passenger1.| Report Duplicate | Flag | PURGE
Amdocs - 0of 0 votes
AnswersGiven an array of strings as input, return an array of all strings that have repeated chars that appear together. For e.g. in "hello" l and in "summer" s is a repeated char that appears together. However in "robot" o is not a repeated char as it does not appear together.
- ruhi July 24, 2014 in United States
repeatChars({"hello","robot","summer","elephant"}) = {"hello","summer"}| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 2of 2 votes
AnswersYou have been given an array of int as input. Return true if there exist 2 numbers in the array whose sum is equal to the sum of the rest of the numbers in the array.
- ruhi July 05, 2014 in United States
twoSum({2,11,5,1,4,7}) = true (11+4 = 2+5+1+7)| Report Duplicate | Flag | PURGE
Amdocs - -3of 3 votes
AnswerGiven N Vertices and M Edges. Each Edge connects two vertices.
- justhack4fun688 February 08, 2014 in United States
There is at most one way to move between each pair of vertices.
Each vertex is either locked or unlocked .There is a perfect path between two different vertices if both vertices are unlocked, and are connected with each other by some way.
The question is What is the number of pairs of vertices, which have a perfect path between them and also What is the number of the vertices, which have at least one perfect path passing through that vertex.
NOTE : There is at most one way to move between each pair of vertices, that is, the given graph is a forest
EXAMPLE : Say we have 6 Vertices and 5 Edges.
A=[1,1,1,1,1,0] It shows that A[i]=1 if ith vertex is unlocked otherwise 0.
Let the connected pair of vertices are : (1,2),(1,6),(1,5),(2,4),(4,3)
Here ,Answer for first question is 10 and second one is 5.
So,interviewer asked me to device an efficient algorithm for it and also code it in c++| Report Duplicate | Flag | PURGE
Amdocs Software Engineer Intern Algorithm - 0of 0 votes
AnswersHow to partition an array of integers into subarrays so that the average of the two subarrays becomes equal, in efficient way?....
- ajayjohnian1 December 04, 2013 in United States| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
Answerhow to convert array into sub arrays
- ajayjohnian1 December 04, 2013 in United States| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
Answerswrite the jquery for simultaneous dropdown and pagination i.e. we have 500 rows in a table and we want to display those rows. pagination will be used and also dropdown means if no of rows to be displayed is 10 per page then 10 rows per page should be displayed and dropdown changes should go with pagination.
- manisha khan July 30, 2013 in India| Report Duplicate | Flag | PURGE
Amdocs Applications Developer JavaScript - 0of 0 votes
AnswerA tuple can contain a list as an element.
- paramjit1992singh November 02, 2012 in India for python basics
True
or
False| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
AnswersAll O(1) functions take exactly the same amount of time to run.
- paramjit1992singh November 02, 2012 in India for python basics
True
or
False| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
AnswersAfter a mutable object has been created, its identity can change.
- paramjit1992singh November 02, 2012 in India for python basics
True
or
False| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
AnswerAfter a mutable object has been created, its value can change.
- paramjit1992singh November 02, 2012 in India for python basics
True
or
False| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
AnswersFind the kth smallest element in an array. How can we do it without sorting the array.
- samant.bit July 13, 2012 in India| Report Duplicate | Flag | PURGE
Amdocs Software Engineer / Developer - 0of 0 votes
AnswerBinu is an aspiring pattern-artist. He spends his free time creating patterns using the computer keyboard. One day, he was creating a random pattern using “/”and “\” characters and during the process, realized that his pattern contained open paths and enclosures (see figure alongside). In this figure, Binu has drawn 6 characters (using either “/” or “\”) each in 4 rows on a standard graph paper. He counted two enclosures (marked with dots), the larger one of 16 squares size and the smaller one of 4 squares size. He also noticed several open paths (non-closed spaces) which are not relevant in the context of this problem. Your task is to help Binu by writing a program that counts all the enclosures in a given pattern and find the size of the largest enclosure. For simplicity, we will not dwell into cases where there are enclosures within enclosures (your code doesn’t need to consider such cases). You may note in the figure that each “/” or “\” is equivalent to 2 units in the graph.
- Master March 29, 2012 in India
Input:-
The input file would contain multiple independent test cases, each test case being a pattern, drawn by Binu. Each test case begins with two integers a and b (1 <= a <= 50, 1 <= b <= 50) where a and b represents the length and breadth of the pattern. The next b lines contain a characters each which are either “/” or “\” (no whitespaces in between). The input ends with a test case having a and b as 0. In the above figure, a = 6, b = 4.
Output:-
For each test case, your code needs to output (on a separate line) two integers x and y (separated by a single whitespace) where x is the total number of enclosures in that pattern and y is the size of the biggest enclosure. In the above figure, the output would be 2 16; meaning, there are 2 enclosures & the size of the largest enclosure is 16 squares. If there are no enclosures in a pattern, you need to output 0 0. If two or more enclosures have the same size (and that happens to be the maximum size), you need to output that size.
EX I/P:
6 4
\//\\/
\///\/
//\\/\
\/\///
3 3
///
\//
\\\
0 0
EX O/P
2 16
0 0
Note:
/\
\/
will have 4 diamond shape squares in it. They have given a image. not able to add it here.| Report Duplicate | Flag | PURGE
Amdocs C - 0of 0 votes
AnswersWhich is better ++i or i++ and why ?
- alpha July 08, 2011| Report Duplicate | Flag | PURGE
Amdocs - 0of 0 votes
AnswersGiven an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space].
- DInesh April 07, 2011
e.g. If input array is [1,3,6,8,-5,-2,3,8] It should be converted to: [-5,-2,1,3,3,6,8,8]| Report Duplicate | Flag | PURGE
Amdocs Testing / Quality Assurance Algorithm Arrays