Commit 237c7260 authored by sachin.shukla's avatar sachin.shukla

Adding questions

parent 2b3b0cb9
Write the implementaion for the method which takes a positive (or zero) integer value and converts it into a binary equivalent without using any Math library.
However, if the input argument is negative, it should throw some exception as so far it doesn't still supports
to convert the negative number into binary.
Sample Input: if a given number is <b>35</b>, the method should return <b>100011</b>
write your code under <b> src/main/java/exam/ConvertToBinary#toBinary() - (3) Marks.</b> method
----------------
Write the implementation of a method which takes an integer array and it shifts all the elements to one right
however the last element would be placed at the first position as it cannot go further right in the same array and hence goes to first place.
No new array needs to be created, the operation should be performed in the same array.
e.g. if the array input is <b>1,2,3,4,5</b>
then the implementation of shift method should shift the element and also the last element (5) should come to the first place
and hence the final output should be <b>5,1,2,3,4</b>
write your code under <b> src/main/java/exam/ShiftElementsInArray#shift() - (3) Marks.</b> method
----------------
For a given total (T), and a weight (w) find the number of combinations where total T can be achieved by summing up For a given total (T), and a weight (w) find the number of combinations where total T can be achieved by summing up
all the weights range from 1 to w. all the weights range from 1 to w.
...@@ -18,4 +43,11 @@ all the weights range from 1 to w. ...@@ -18,4 +43,11 @@ all the weights range from 1 to w.
`2,3` `2,3`
write your code under <b> exam.CountCombinations#getNumberOfWays() </b> method write your code under <b> src/main/java/exam/CountCombinations#getNumberOfWays() - (4) Marks.</b> method
\ No newline at end of file
-----
<b><i>For any of the above questions, donot change the signature of the provided methods,
just write your code inside the give methods as mentioned in each question!</i></b>
\ No newline at end of file
package exam;
public class ConvertToBinary {
public String toBinary(final int n) {
//TODO write your code here to achieve the desired result as explained in Readme file for this problem.
return "";
}
}
package exam;
public class ShiftElementsInArray {
public void shift(int[] arr) {
//TODO write your code here to achieve the desired result as explained in Readme file for this problem.
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment