Get nth node linked list problem Given a singly linked list. Write a function that returns the nth node from the end of the list. How to find nth node in linked list Let (n) be the position (from the …

# Tag Archives: Cpp - Page 5

## Modified binary search

Given a sorted array of (n) integers that has been rotated an unknown number of times. Give a log(n) algorithm that finds an element in the array. Assume the array has no duplicates.

## Maximum of two numbers in c

Maximum of two numbers without comparison Write a C++ function which takes two positive integers x and y as input then return x if x > y otherwise return y. Assume x is not equal to y. You are not …

## MCSS – Linear time complexity

Problem Given an array of N integers. The array is expected to contain positive as well as negative numbers. Find the maximum contiguous subsequence sum (MCSS) of the array. For example the MCSS of {2, -4, 1, 2} is 3 …

## Maximum contiguous subsequence sum C++

Maximum contiguous subsequence sum problem Given an array of N integers. The array is expected to contain positive as well as negative numbers. Find the maximum contiguous subsequence sum (MCSS) of the array. For example the MCSS of {2, -4, …

## Fibonacci numbers list

Fibonacci numbers problem Write a program to compute the Fibonacci sequence number of a given integer. Your algorithm must run in linear time ie O(N). What is the fibonacci sequence Definition: Fibonacci number of (N) is the sum of Fibonacci …

## String to integer c++

String to integer in c++ Given an integer number in string format, for example “12345”. Write a program or function to convert a string to integer in C without using library. String to integer algorithm Loop through the characters of …