IBM Coding Questions 2022
Algorithm:
- Check if smaller of two number divide larger number. If yes, HCF is smaller
- Else, Start from smaller/2 to 1 and check if current number divides both the input numbers.
- If yes, then current number is required HCF.
Algorithm:
Sum of arithmetic series is ((n / 2) * (2 * a + (n - 1) * d)) Where a is First term d is Common difference n is No of terms
Algorithm:
- Keep dividing number by 2 until it becomes 0.
- The remainder obtained on dividing on each run is stored and converted to right format to return.
Algorithm:
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation
Fn = Fn-1 + Fn-2. where F1 = 1 and F2 = 1.
Algorithm:
- Traverse through sentence
- If character is not a,e,i,o,u r store character in new string else ignore.
Algorithm:
- Get the length of input string.
- Do following while low index ‘l’ is smaller than high index ‘h’ where l is initialised to 0 and high to n-1
- If str[l] is not same as str[h], then return false.
- Increment l and decrement h, i.e., do l++ and h–.
- If all character match, return true.
No comments