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.
Category: Kotlin
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.
Real-world application of dynamic programming in image resizing[Seam Carving]
Seam Carving is a content Aware resizing algorithm developed by Shai Avidan, of Mitsubishi Electric Research Laboratories (MERL), and Ariel Shamir...
[Program][Kotlin] Count words from a file
import java.io.File fun main(args: Array<String>){ val file = File("src\\text.txt") val count = file.readText().split(" ").size println(count) }
[Program][Kotlin] Count Numbers in a File
import java.io.File fun main(args: Array<String>) { val file = File("src\\words_with_numbers.txt") val count: Int = file.readLines().count { try { Integer.parseInt(it) return@count true } catch (e: NumberFormatException) { return@count false } } println(count) }
[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

