Tag: Cpp

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 numbers of (N-1) and (N-2). In other words, the fibonacci numbers list formula: Fibonacci(N) =

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 the string representing the integer number. Get the integer value of the current digit by

Reverse string in c++

Problem A typical interview question is to describe an algorithm to reverse a string of characters. Solution We need one pass through the characters of the string to get the string length or use a built in function to get that. Once the length of the string is found then one for loop can be