0% found this document useful (0 votes)
15 views6 pages

L1 Part2

The document contains a list of 20 easy-level programming questions, each with a brief description and examples. Topics include finding minimum and maximum in arrays, reversing arrays, checking for palindromes, counting vowels, and performing binary search. It also covers mathematical concepts like GCD, LCM, and Fibonacci numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

L1 Part2

The document contains a list of 20 easy-level programming questions, each with a brief description and examples. Topics include finding minimum and maximum in arrays, reversing arrays, checking for palindromes, counting vowels, and performing binary search. It also covers mathematical concepts like GCD, LCM, and Fibonacci numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Easy-Level Programming Questions

1) Find Minimum in Array


Given an array of integers, return the minimum element.

Example 1:
Input: nums = [3,1,4,2]
Output: 1

Example 2:
Input: nums = [10,20,5,30]
Output: 5

2) Reverse an Array
Given an array of integers, return the reversed array.

Example 1:
Input: nums = [1,2,3]
Output: [3,2,1]

Example 2:
Input: nums = [10,5,7]
Output: [7,5,10]

3) Find First Occurrence


Given an array and a target element, return the first index where the element appears. If not
found, return -1.

Example 1:
Input: nums = [1,2,3,4,3], target = 3
Output: 2

Example 2:
Input: nums = [5,6,7], target = 8
Output: -1

4) Check if Array is Sorted


Given an array, return True if it is sorted in non-decreasing order, otherwise return False.

Example 1:
Input: nums = [1,2,3,4]
Output: True
Example 2:
Input: nums = [1,3,2,4]
Output: False

5) Find the Length of a String


Given a string, return its length.

Example 1:
Input: s = 'hello'
Output: 5

Example 2:
Input: s = 'python'
Output: 6

6) Count Vowels in a String


Given a string, return the number of vowels (a, e, i, o, u) in it.

Example 1:
Input: s = 'hello'
Output: 2

Example 2:
Input: s = 'world'
Output: 1

7) Check if a String is a Palindrome


Given a string, return True if it is a palindrome, otherwise False.

Example 1:
Input: s = 'racecar'
Output: True

Example 2:
Input: s = 'hello'
Output: False

8) Convert String to Uppercase


Given a string, return the uppercase version of the string.

Example 1:
Input: s = 'hello'
Output: 'HELLO'
Example 2:
Input: s = 'Python'
Output: 'PYTHON'

9) Binary Search
Given a sorted array and a target, return the index of the target if found, otherwise return -
1.

Example 1:
Input: nums = [1,3,5,7], target = 5
Output: 2

Example 2:
Input: nums = [2,4,6,8], target = 3
Output: -1

10) Find Maximum in Array


Given an array, return the maximum element.

Example 1:
Input: nums = [1,4,3,7]
Output: 7

Example 2:
Input: nums = [10,20,30]
Output: 30

11) Count Even Numbers in Array


Given an array, return the count of even numbers.

Example 1:
Input: nums = [1,2,3,4]
Output: 2

Example 2:
Input: nums = [10,15,20,25]
Output: 2

12) Check if a Number is Prime


Given a number, return True if it is prime, otherwise False.

Example 1:
Input: num = 7
Output: True

Example 2:
Input: num = 10
Output: False

13) Find Factorial of a Number


Given a number, return its factorial.

Example 1:
Input: num = 5
Output: 120

Example 2:
Input: num = 3
Output: 6

14) Find Fibonacci Number


Given an integer n, return the nth Fibonacci number.

Example 1:
Input: n = 5
Output: 5

Example 2:
Input: n = 7
Output: 13

15) Find the GCD of Two Numbers


Given two numbers, return their greatest common divisor (GCD).

Example 1:
Input: a = 12, b = 18
Output: 6

Example 2:
Input: a = 7, b = 13
Output: 1

16) Find the LCM of Two Numbers


Given two numbers, return their least common multiple (LCM).

Example 1:
Input: a = 4, b = 5
Output: 20

Example 2:
Input: a = 6, b = 8
Output: 24

17) Find Sum of Digits


Given a number, return the sum of its digits.

Example 1:
Input: num = 123
Output: 6

Example 2:
Input: num = 456
Output: 15

18) Remove Duplicates from Array


Given an array, return an array with duplicates removed.

Example 1:
Input: nums = [1,2,2,3,4,4]
Output: [1,2,3,4]

Example 2:
Input: nums = [5,5,6,7,7]
Output: [5,6,7]

19) Merge Two Sorted Arrays


Given two sorted arrays, merge them into one sorted array.

Example 1:
Input: nums1 = [1,3,5], nums2 = [2,4,6]
Output: [1,2,3,4,5,6]

Example 2:
Input: nums1 = [10,20], nums2 = [15,25]
Output: [10,15,20,25]

20) Find Second Largest Element


Given an array, return the second largest element.

Example 1:
Input: nums = [1,5,3,9,7]
Output: 7

Example 2:
Input: nums = [10,20,30,40]
Output: 30

You might also like