Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
634 views
in Online Assessments by Expert (108,170 points) | 634 views

1 Answer

0 like 0 dislike
Best answer

Questions:

 

  1. Convert Binary Numbers in Single Linked List to Number
  2. Count the number of Sundays for a given year
  3. Find circular primes less than n [Unsolved]
  4. Maximum length subsequence with difference between adjacent elements as either 0 or 1 [Unsolved]
  5. Determines whether or not n is a perfect number (The easiest one in this list)

 

Solutions:

 

  1. Convert Binary Numbers in Single Linked List to Number
var getNumber = function(binary) {
let num = binary.data + "";

while (binary.next !== null) {
 binary = binary.next;
 //add the next element’s value onto the current binary 
 num += binary.data;
}
let tmp = "";
num.split("").reverse().forEach((x,i) => {
number = BigInt(Math.pow(2, i) * x) + BigInt(tmp);
});
return tmp.toString();
};
  1. Count the number of Sundays for a given year
var sundays = 0;
    for (var month = 1; month<=12; month++) {
        if (new Date(year, month-1, 1).getDay() == 0) {
            sundays++;
        }
    }
return sundays

 

by Expert (108,170 points)

Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .