0% found this document useful (0 votes)
3 views

Java B

The document lists functions for common array and string operations like finding maximum/minimum elements, reversing, sorting, removing duplicates, counting occurrences, concatenating, rotating arrays, checking for palindromes, counting vowels/words, converting case, and more.

Uploaded by

Kya Chaiye
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Java B

The document lists functions for common array and string operations like finding maximum/minimum elements, reversing, sorting, removing duplicates, counting occurrences, concatenating, rotating arrays, checking for palindromes, counting vowels/words, converting case, and more.

Uploaded by

Kya Chaiye
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1) Initialize and Print an Array:

a) Initialize an array of 10 integers and print each element.


2) Find Maximum Element in Array:
a) Write a function to find the maximum element in an array of integers.
3) Reverse an Array:
a) Write a function to reverse an array of integers.
4) Sum of Array Elements:
a) Write a function to calculate the sum of all elements in an array of integers.
5) Count Occurrences of an Element:
a) Write a function that takes an array of integers and an integer, and returns the
number of times the integer occurs in the array.
6) Concatenate Two Arrays:
a) Write a function that takes two arrays of integers and returns a new array that is the
concatenation of both arrays.
7) Sort an Array:
a) Write a function to sort an array of integers in ascending order.
8) Remove Duplicates from Array:
a) Write a function that removes duplicate elements from an array of integers.
9) Find Second Largest Element:
a) Write a function to find the second largest element in an array of integers.
10) Rotate Array:
a) Write a function to rotate an array of integers to the right by a given number of steps.
11) Check for Palindrome String:
a) Write a function that checks if a given string is a palindrome.
12) Count Vowels in String:
a) Write a function that counts the number of vowels in a given string.
13) Reverse a String:
a) Write a function to reverse a given string.
14) Remove a Character from String:
a) Write a function that removes all occurrences of a given character from a string.
15) Check if Two Strings are Anagrams:
a) Write a function that checks if two given strings are anagrams of each other.
16) Count Words in String:
a) Write a function to count the number of words in a given string.
17) Replace Character in String:
a) Write a function that replaces all occurrences of a given character in a string with
another character.
18) Find Longest Word in String:
a) Write a function to find the longest word in a given string.
19) String Contains Substring:
a) Write a function that checks if a given string contains a given substring.
20) Convert String to Uppercase:
a) Write a function that converts a given string to uppercase.
21)
22) Merge and Sort Arrays:
a) Write a function that takes two sorted arrays of integers and returns a single sorted
array that combines both arrays.
23) Find Missing Number:
a) Write a function that takes an array of integers from 1 to n with one number missing,
and returns the missing number.
24) Count Even and Odd Numbers:
a) Write a function that takes an array of integers and returns an array with two
elements: the count of even numbers and the count of odd numbers.
25) Transpose a Matrix:
a) Write a function that takes a 2D array (matrix) and returns its transpose (i.e., rows
become columns and columns become rows).
26) Find Intersection of Arrays:
a) Write a function that takes two arrays of integers and returns a new array containing
only the elements that are present in both arrays.

27) Merge and Sort Arrays:


a) Write a function that takes two sorted arrays of integers and returns a single sorted
array that combines both arrays.
28) Find Missing Number:
a) Write a function that takes an array of integers from 1 to n with one number missing,
and returns the missing number.
29) Count Even and Odd Numbers:
a) Write a function that takes an array of integers and returns an array with two
elements: the count of even numbers and the count of odd numbers.
30) Transpose a Matrix:
a) Write a function that takes a 2D array (matrix) and returns its transpose (i.e., rows
become columns and columns become rows).
31) Find Intersection of Arrays:
a) Write a function that takes two arrays of integers and returns a new array containing
only the elements that are present in both arrays.

You might also like