Summary of "Can you ? Virtusa Important Coding Questions | Virtusa Online Assessment Test 2025 | Tekno UF"

Summary of the Video: "Can you ? Virtusa Important Coding Questions | Virtusa Online Assessment Test 2025 | Tekno UF"

Main Ideas and Concepts:

Detailed Explanation of the Coding Problem:

Methodology / Instructions to Solve the Problem:

Python Solution:

  1. Initialize an empty list to store unique elements.
  2. Iterate over each element in the input array.
  3. For each element, check if it is not already present in the unique elements list.
  4. If not present, append it to the unique elements list.
  5. After the loop ends, return the list of unique elements.
  6. Print the returned list.

Code Logic (in brief):

def remove_duplicates(array):
    unique_elements = []
    for num in array:
        if num not in unique_elements:
            unique_elements.append(num)
    return unique_elements

# Example usage:
input_array = [1, 2, 2, 3, 4, 4, 5]
print(remove_duplicates(input_array))  # Output: [1, 2, 3, 4, 5]

Java Solution:

  1. Use a List<Integer> to store unique elements.
  2. Iterate over the input array.
  3. For each element, check if the list does not contain the element using the contains() method.
  4. If not contained, add the element using the add() method.
  5. Return the list after iteration.
  6. Print the returned list.

Code Logic (in brief):

import Java.util.ArrayList;
import Java.util.List;

public class RemoveDuplicates {
    public static List<Integer> RemoveDuplicates(int[] array) {
        List<Integer> uniqueElements = new ArrayList<>();
        for (int num : array) {
            if (!uniqueElements.contains(num)) {
                uniqueElements.add(num);
            }
        }
        return uniqueElements;
    }

    public static void main(String[] args) {
        int[] input = {1, 2, 2, 3, 4, 4, 5};
        System.out.println(RemoveDuplicates(input));  // Output: [1, 2, 3, 4, 5]
    }
}

Additional Notes:

Speakers / Sources Featured:

Category ?

Educational

Share this summary

Video