Question: HPE | Recent Online Assessment 2025 | Tree Optimization & IP Parsing | Latest HPE Placement Questions 2025 | String Validation & Dynamic Programming
0
Entering edit mode

Question 1: Location Detection

Problem Statement:

The system should identify a user's region based on their IP address.

IPv4 addresses are written as four numbers separated by periods, like "127.10.20.30". Each number is called an octet. Based on the first octet, addresses fall into one of five regions:

  1. 0.0.0.0 – 127.255.255.255
  2. 128.0.0.0 – 191.255.255.255
  3. 192.0.0.0 – 223.255.255.255
  4. 224.0.0.0 – 239.255.255.255
  5. 240.0.0.0 – 255.255.255.255

You are given a list of IP addresses. For each one, check if it is valid. If it is valid, return the region index (1 through 5). If it is not valid, return -1.

 


Question 2: No Ancestor Subset

Problem Statement:

Given a tree with tree_nodes nodes, where each node i has an associated weight weight[i] (1-based indexing). The tree is rooted at node 1.

A subset of nodes is called "good" if there is no pair of nodes where one node is an ancestor of the other.

Find the maximum sum of weights from nodes that form a good subset.

Note: A node u is an ancestor of node v if it lies on the direct path from the root to node v.

ADD COMMENTlink 23 hours ago admin 1.8k

Login before adding your answer.

Similar Posts
Loading Similar Posts