21. Create a component that converts a hardcoded decimal number to its binary representation and displays it.

Required Input:

Decimal: 25

Expected Output:

Binary Representation: 11001

Code In React

import React from "react";
 
 const DecimalToBinary = () => {
  return (
  <div>
  {/* Display the binary representation */}
  </div>
  );
 };
 
 export default DecimalToBinary;

Need help ?

Click on Hint to solve the question.

22. Write a component that calculates the GCD (Greatest Common Divisor) of two hardcoded numbers and displays it.

Required Input:

Numbers: 56 and 98

Expected Output:

GCD: 14

Code In React

import React from "react";
 
 const CalculateGCD = () => {
  return (
  <div>
  {/* Display the GCD */}
  </div>
  );
 };
 
 export default CalculateGCD;

Need help ?

Click on Hint to solve the question.

23. Create a component that validates a hardcoded string as a valid email address and displays the result.

Required Input:

Expected Output:

Is Valid Email: true

Code In React

import React from "react";
 
 const ValidateEmail = () => {
  return (
  <div>
  {/* Display email validation result */}
  </div>
  );
 };
 
 export default ValidateEmail;

Need help ?

Click on Hint to solve the question.

24. Build a component that finds the maximum product of any two numbers in a hardcoded array and displays the result.

Required Input:

Array: [5, -2, 3, 1, -4]

Expected Output:

Maximum Product: 20

Code In React

import React from "react";
 
 const MaxProduct = () => {
  return (
  <div>
  {/* Display the maximum product */}
  </div>
  );
 };
 
 export default MaxProduct;

Need help ?

Click on Hint to solve the question.

25. Write a component that parses a hardcoded HTML-like string and displays the tag hierarchy.

Required Input:

String: '<div><p>Hello</p></div>'

Expected Output:

Tag Hierarchy: ['div', 'p']

Code In React

import React from "react";
 
 const ParseHTMLTags = () => {
  return (
  <div>
  {/* Display the tag hierarchy */}
  </div>
  );
 };
 
 export default ParseHTMLTags;

Need help ?

Click on Hint to solve the question.

26. Create a component that finds the longest consecutive sequence in a hardcoded array of integers and displays the result.

Required Input:

[100, 4, 200, 1, 3, 2]

Expected Output:

Longest Sequence: 4

Code In React

import React from "react";
 
 const LongestSequence = () => {
  return (
  <div>
  {/* Display the longest sequence */}
  </div>
  );
 };
 
 export default LongestSequence;

Need help ?

Click on Hint to solve the question.

27. Build a component that simulates a simple LRU (Least Recently Used) Cache and displays the cache contents after each operation.

Required Input:

[1, 2, 3, 4, 2, 5]

Expected Output:

Cache Contents: [3, 5, 2]

Code In React

import React, { useState } from "react";
 
 const LRUCache = () => {
  return (
  <div>
  {/* Display the cache contents */}
  </div>
  );
 };
 
 export default LRUCache;

Need help ?

Click on Hint to solve the question.

28. Create a component that rotates a hardcoded 2D matrix by 90 degrees clockwise and displays the result.

Required Input:

[[1, 2, 3], [4, 5, 6], [7, 8, 9]]

Expected Output:

Rotated Matrix: [[7, 4, 1], [8, 5, 2], [9, 6, 3]]

Code In React

import React from "react";
 
 const RotateMatrix = () => {
  return (
  <div>
  {/* Display the rotated matrix */}
  </div>
  );
 };
 
 export default RotateMatrix;

Need help ?

Click on Hint to solve the question.

29. Write a component that finds all subsets of a hardcoded array and displays them.

Required Input:

[1, 2, 3]

Expected Output:

Subsets: [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]

Code In React

import React from "react";
 
 const FindSubsets = () => {
  return (
  <div>
  {/* Display all subsets */}
  </div>
  );
 };
 
 export default FindSubsets;

Need help ?

Click on Hint to solve the question.

30. Create a component that evaluates a hardcoded postfix expression and displays the result.

Required Input:

"5 1 2 + 4 * + 3 -"

Expected Output:

Result: 14

Code In React

import React from "react";
 
 const PostfixEvaluator = () => {
  return (
  <div>
  {/* Display the evaluated result */}
  </div>
  );
 };
 
 export default PostfixEvaluator;

Need help ?

Click on Hint to solve the question.

ad vertical

3 of 3