Open in app
Home
Notifications
Lists
Stories

Write
Samarth Sewlani
Samarth Sewlani

Home

Nov 8, 2021

3D Surface Area HackerRank Problem

3D Surface Area | HackerRank Find the surface area of a 3D Toywww.hackerrank.com Task:- Given a matrix of ‘m’ rows and ’n’ columns, each describing the height of the bar at that block, find the surface area of the resulting 3D figure. For better understanding see the example and figure in the question link. Approach:- For getting the surface area of the 3D…

Competitive Programming

1 min read


Oct 7, 2021

Substrings with single character

Task:- Given a string, find the number of substrings in which all the characters are the same. For eg:- input = “aabccc” , answer = 10 Explanation:- The substrings which have same characters are - “a”(0), “aa”(0–1) , “a”(1) , “b”(2) , “c”(3) , “cc” (3–4), “ccc”(3–5) , “c”(4) …

Competitive Programming

2 min read


Jul 8, 2021

Frequency of Maximum Value HackerRank Problem:-

The question was appeared in coding test of one of the company on HackerRank. Task:- Given an array ‘nums’ of length N containing positive integers and an array ‘query’ of length ‘Q’ containing indexes, print/store for each query the count of maximum value in the sub-array starting at index ‘i’…

Competitive Programming

2 min read


May 4, 2021

Max Min HackerRank Problem

Max Min | HackerRank You will be given a list of integers, , and a single integer . You must create an array of length from elements of such…www.hackerrank.com Task:- Given an array of integers and value ‘k’. Calculate the minimum unfairness value possible with an array of ‘k’ elements from the given array. Unfairness = max(arr) — min(arr) For eg: arr = [ 2, 8, 2, 4, 4, 1 ] and k = 4 The array [ 2…

Competitive Programming

1 min read


May 4, 2021

Pairs HackerRank Problem

Pairs | HackerRank Given an array of integers and a target value, determine the number of pairs of array elements that have a difference…www.hackerrank.com Task:- Given an array ‘arr’ and an integer ‘k’. Find the number of pairs whose difference is equal to value k. For eg:- arr = [ 4, 6, 8, 10, 7] and k = 2. The pairs which satisfy the conditions are (4, 6), (6, 8), (8, 10). So the…

Competitive Programming

2 min read


May 3, 2021

Sherlock and the Valid String HackerRank Problem

Sherlock and the Valid String | HackerRank Sherlock considers a string to be if all characters of the string appear the same number of times. It is also if he can…www.hackerrank.com Task:- Given a string s, check whether string can be converted to a valid string or not by deleting at the most once character. A string is said to be valid if all the characters in the string occur the same number of times.

Competitive Programming

2 min read


Mar 25, 2021

Palindrome queries HackerEarth Problem

Palindrome queries | Practice Problems Prepare for your technical interviews by solving questions that are asked in interviews of various companies…www.hackerearth.com Task:- Given a string str and Q queries, each query contains left index ‘l’ and right index ‘r’. For each query print whether the substring formed from ‘l’ to ‘r’ can be rearranged to form a palindrome or not. For eg: str = “abbacd”

Competitive Programming

2 min read


Mar 19, 2021

Range Sum HackerEarth Problem

Range sum | Practice Problems Prepare for your technical interviews by solving questions that are asked in interviews of various companies…www.hackerearth.com Task:- Given an array of N integers and Q queries each denoting l (left-index) and r ( right-index), print sum of subarray from index l to r (inclusive) . For eg: arr = [ 1, 5, 6, 2, 3 ], N = 5 Q = 3 Queries: 1) (1, 5) …

Competitive Programming

2 min read

Range Sum HackerEarth Problem
Range Sum HackerEarth Problem

Mar 19, 2021

Merge Clashing Intervals JPMC

The question appeared in the coding test taken by JP Morgan Chase in one of the placement drives. Task :- Given a list of intervals(starting time,ending time), merge all the clashing intervals and return the sorted non-clashing intervals. For eg: intervals = [ (1, 5), (7, 11),(15, 20), (3, 9)…

Competitive Programming

2 min read


Mar 19, 2021

Number of Substrings JPMC

The question appeared in the coding test taken by JP Morgan Chase in one of the placement drives. Task :- Given a string of 0s and 1s, find the number of substrings that match the following conditions : The number of 1s and 0s in the substring are equal. The…

Competitive Programming

2 min read

Samarth Sewlani

Samarth Sewlani

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Knowable