[Java] Rotate array left or right n times

package com.abstractProgrammer; import java.util.Arrays; import java.util.stream.IntStream; public class Main { public static int[] rotateLeft(int[] arr, int numberOfRotation) { int[] temp = new int[numberOfRotation]; int finalNumberOfRotation = numberOfRotation % arr.length; System.arraycopy(arr, 0, temp, 0, numberOfRotation); IntStream .range(numberOfRotation, arr.length) .forEach(i -> arr[i - finalNumberOfRotation] = arr[i]); System.arraycopy(temp, 0, arr, arr.length - numberOfRotation, numberOfRotation); return arr; } public … Continue reading [Java] Rotate array left or right n times

[TCS NQT][2021] Find area of circle and print it up to 2 decimals.

both the coding questions of TCS NQT were very easy this time, This is one of them, hidden in the story of Jack who needs to find out the area of his circular ground, and he knows the radius( good for us 😬 ) the only condition is - radius 'r' must satisfy the condition … Continue reading [TCS NQT][2021] Find area of circle and print it up to 2 decimals.

[TCS NQT][2021] Mirror characters of a string

this is another one, wrapped in another story that someone is building a cryptographic program and they need to convert 'a' to 'z' , 'b' to 'x' and so on, Also known as mirror characters - Python - 1st approach chars = [chr(i) for i in range(97, 123)] reversed_char = [chr(i) for i in reversed(range(97, … Continue reading [TCS NQT][2021] Mirror characters of a string

Replace every letter with its adjacent letter and convert all vowels to uppercase.

C++ #include<iostream> using namespace std; bool isAlphabet(char c) { if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) return true; return false; } bool isVowel(char c) { char vowels[] = {'a', 'e', 'i', 'o', 'u'}; for (char vowel : vowels) { if (vowel == c) { return true; … Continue reading Replace every letter with its adjacent letter and convert all vowels to uppercase.

[Programmers.Io] ‘CHOCX’ Cake Inventory

‘CHOCX’ is a bakery specialized in chocolate cakes. Their cake formula is - each cake contains 40% Bread, 10% Sugar, 30% Cream, 20% chocolate. They accept order via mail for X kg cake. In response, they confirm if they can deliver the cake with a “Thank you” or if they can’t with a “Sorry” note. When they respond they make sure, if any component is greater and equal to the required component, they retain 1 kg of each component Bread, Sugar, Cream, Chocolate in their inventory.

[Programmers.IO] minimum Assistance Problem

A finance company wants to hire some support assistance based upon their cases arrival and solved time but the company is confused with what is the minimum number of assistance required to handle the cases. Help the company to calculate minimum number to assistance can handle the cases. WAP to take input of 2 array/list (One for Case Arrival Time another of Case Solved Time), and your program should return the minimum number of assistance required for the company. Note: Assign assistance in such a way that no cases needed to be wait to arrive.