Search Questions

Company: SHARECHAT

#1

One block
You are working in the resource distribution team of your company. A One block is a block of data having exactly one resource which has value 1. You are given an array Arr containing Nresource values.
What is the number of ways to divide the array into continuous blocks such that each block is One block.
NOTE - If we cannot form a block with One block, then output 0

Function descri

Asked in: SHARECHAT


Buyer: 1
Code Size:
#2

Recursive Land Division

A country consists of N regions, each containing a specific number of towns. The government has decided to split the country into two separate nations in a way that minimizes the absolute difference between the total number of towns in each new nation.

Each region is connected to another region through roads, forming a tree structure (i.e., an undirected connected gra

Asked in: SHARECHAT


Buyer: 0
Code Size:
#3

Task
Calculate the number of pairs of investment (i, j) such that the return is a perfect square.
Example 1
Assumptions
Input
N = 4
Output: 6

Approach
(1, 1), (1, 4), (2, 2), (3, 3), (4, 1), and (4, 4) are the possible pairs.
Square Investment
Bob and John both have N dollars each and want to invest some money in Jack.
They will invest amounts i, j (1 โ‰ค i, j โ‰ค N). Jack has promised th

Asked in: SHARECHAT


Buyer: 0
Code Size:
#4

Question 2

Implement a Least Frequently Used (LFU) cache data structure of size cacheSize that handles two types of queries: GET and PUT.

A GET query attempts to retrieve the value of a given key.

If the key is present in the cache, it is returned.

Otherwise, it returns -1.

A PUT query updates or inserts a key-value pair into the cache.

When the cache is full, the least frequentl

Asked in: ShareChat


Buyer: 0
Code Size:
#5

A forklift operator navigates products within an automotive parts warehouse. The dashboard displays a real-time map showing open and blocked sections as an n x m matrix of 1's (open) and 0's (blocked). The operator starts at the top-left corner of the map at warehouse[0][0] and aims to reach the bottom-right corner at warehouse[n-1][m-1].

Movements can only be made to the right or downward. Giv

Asked in: ShareChat


Buyer: 1
Code Size:
#6

1. Question 1
Given a chessboard of n rows (top to bottom) and n columns (left to right). In each move, a knight moves either:
2 column positions and 1 row position
2 row positions and 1 column position
In other words, a move is 2 steps along one axis and 1 step along a perpendicular axis.
Given a starting position A and ending position B, calculate the minimum number of moves needed by the k

Asked in: ShareChat


Buyer: 0
Code Size:
#7

Efficient Network
There are n computer systems connected together to form a network. The network can be represented as a rooted tree (rooted at master computer 1), where the connections are described using two arrays connect_from[]and connect_to[]. Each pair (connect_from[i], connect_to[i]) denotes an undirected edge between the two computers. Additionally, each computer has a value assigned to i

Asked in: ShareChat


Buyer: 0
Code Size:
#8

Subsequence Sort

Given a binary string binary consisting of characters '0' and '1' only, perform the following 0
or more times.
ยท Choose any subsequence, sort the subsequence, and replace the original subsequence with the sorted sequence.
Next, there is an array of strings, arr, of length n, where each string has length / binary/ and consists of characters '0', '1' and '?'. Each '?' characte

Asked in: ShareChat


Buyer: 0
Code Size:
#9

Break The Bricks

There are n bricks arranged in a row at positions numbered from 1 through n, inclusive. There is an array, newtons[n], that contains an integer indicating the number of newtons required to
smash a brick., (A newton is a unit of force.)

There are two hammers, one big and one small. The big hammer can smash any brick with one blow. The small hammer reduces the newtons require

Asked in: ShareChat


Buyer: 0
Code Size: