[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.

Replace Words in a file and print count

JAVA import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; public class ReplaceWords { public static long countWords(String source, String wordToCount) { String[] words = source.split(" "); int count = 0; for (String word : words) { if (word.equals(wordToCount)) count++; } return count; } public static long replaceWords(String filePath , String[] wordsToReplace , String[] wordsToReplaceWith) throws … Continue reading Replace Words in a file and print count

[Kotlin] Check if string is anagram

fun isAnagramSumCheck(string1: String, string2: String): Boolean { val cleanedString1 = cleanString(string1) val cleanedString2 = cleanString(string2) return if (cleanedString1.length != cleanedString2.length) false; else { cleanedString1.toLowerCase().sumBy { it.toInt() } == cleanedString2.toLowerCase().sumBy { it.toInt() } } } fun cleanString(string: String): String { return string.replace( Regex("[^a-zA-Z]"), "") } fun isAnagramCharCheck(string1: String, string2: String): Boolean { val cleanedString1 = cleanString(string1) … Continue reading [Kotlin] Check if string is anagram

[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.

[Program][Kotlin]Rotate Array by N

import java.util.* fun main(args: Array<String>) { val scanner = Scanner(System.`in`) val a = IntArray(scanner.nextInt()) { scanner.nextInt() } var r = scanner.nextInt() if (r > a.size) r = r % a.size if (r != a.size) { repeat(r) { val last = a.last() var prev = a[0] var temp: Int for (i in 1..a.lastIndex) { temp = … Continue reading [Program][Kotlin]Rotate Array by N