Square Root Integral in Python

Given a number N, find its square root. You need to find and print only the integral part of square root of N. For eg. if number given is 18, answer is 4. Input format : Output Format : Constraints : Understanding the Problem: Given a non-negative integer ‘N’, our objective is to find and … Read more

Word Patterns | Interview Question at Mastercard

Introduction: In the world of string manipulation, unraveling patterns and matching sequences play a pivotal role in various applications. In this tutorial, we’ll embark on a journey to decode word patterns, where we’ll determine if two strings follow the same pattern. Through the lens of Java programming, we’ll explore an efficient approach to tackle this … Read more

Level Order Traversal Technique for Binary Trees

Introduction: In binary trees, exploring their structure and nodes in a systematic manner is crucial for various operations and analyses. One such traversal method is the level order traversal, which traverses the tree level by level, starting from the root node. Through this tutorial, we’ll delve into the intricacies of level order traversal and learn … Read more

Minimum Steps to Reduce a Number to 1 Using Dynamic Programming

Problem Statement: Given a positive integer ‘N’, our objective is to compute and return the minimum number of steps needed to reduce ‘N’ to 1. We have three permissible operations: Understanding the Approach: To efficiently solve this problem, we’ll employ dynamic programming to compute the minimum steps needed for each integer from 1 to ‘N’. … Read more

Maximum Subarray Sum Challenge with Kadane’s Algorithm

Introduction: In the realm of algorithmic problem-solving, the quest for the maximum sum of any contiguous subarray within a given array is a classic challenge. In this tutorial, we’ll embark on a journey to conquer this challenge using Kadane’s algorithm, a powerful tool that operates with a time complexity of O(N). Problem Statement: Given an … Read more

Finding the Longest Palindromic Subsequence

Introduction: Dynamic Programming (DP) is a powerful algorithmic technique used to solve a variety of optimization problems. One classic problem where DP shines is in finding the longest palindromic subsequence in a given string. In this tutorial, we’ll delve into the intricacies of this problem and learn how to tackle it using DP. Problem Statement: … Read more

Questions asked in Data Scientist Interviews Part 7

Interview

In this series we bring new Data Scientist Interview Questions. You can read other tutorials related to same topic on our website. What is Cross Validation? Cross-Validation in Machine Learning is a statistical resampling technique that uses different parts of the dataset to train and test a machine learning algorithm on different iterations. The aim … Read more

Hackerrank | Birthday Candles Problem

Hackerrank

You are in charge of the cake for a child’s birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest. Example candles=[4,4,1,3] The maximum height candles are  4 units high. … Read more

Hackerrank | Min Max Sum of N-1 Elements

Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. Example arr=[1,3,5,7,9] The minimum sum is 1+3+5+7=16 and the maximum sum is 3+5+7+9=24 . The function prints Function Description … Read more

HackerRank Problem | Staircase detail

Staircase detail This is a staircase of size n=4: Its base and height are both equal to 4 . It is drawn using # symbols and spaces. The last line is not preceded by any spaces. Write a program that prints a staircase of size n. Function Description Complete the staircase function in the editor below. staircase has the following parameter(s): Print Print … Read more

Hackerrank | Plus Minus Problem

Python

Given an array of integers, calculate the ratios of its elements that are positive,  negative, and zero. Print the decimal value of each fraction on a new line with  places after the decimal. Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to  10^-4 are acceptable. Example … Read more

Hackerrank Problems | Diagonal Difference

Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix  is shown below: The left-to-right diagonal =1+5+9=15. The right to left diagonal = 3+5+9=17. Their absolute difference is |15-17|=2. Function description Complete the  diagonalDifference function in the editor below. diagonalDifference takes the following parameter: Return Input Format The first line … Read more