0% found this document useful (0 votes)
26 views30 pages

150 Problem Solving Questions

The document outlines various programming exercises and problems related to mathematical operations, loops, and array manipulations, aimed at enhancing problem-solving skills. It includes links to specific tests for each problem, covering topics such as even/odd checks, prime numbers, digit sums, and pattern generation. The exercises are designed to align with NBA SAR guidelines and are part of the training and placement department at Vel Tech High Tech Dr. Rangarajan Dr. Sakunthala Engineering College.

Uploaded by

vh12329cse22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views30 pages

150 Problem Solving Questions

The document outlines various programming exercises and problems related to mathematical operations, loops, and array manipulations, aimed at enhancing problem-solving skills. It includes links to specific tests for each problem, covering topics such as even/odd checks, prime numbers, digit sums, and pattern generation. The exercises are designed to align with NBA SAR guidelines and are part of the training and placement department at Vel Tech High Tech Dr. Rangarajan Dr. Sakunthala Engineering College.

Uploaded by

vh12329cse22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

VEL TECH HIGH TECH

Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE


An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

DEPARTMENT OF TRAINING & PLACEMENT

Operators:

Learn the use of division / and mod % operations to solve problems

1. IS EVEN? : https://tests.mettl.com/authenticateKey/2bd025dc
2. IS ODD? : https://tests.mettl.com/authenticateKey/dbdac2a9
3. Return last digit of the given number :
https://tests.mettl.com/authenticateKey/454f012b
4. Return second last digit of given number :
https://tests.mettl.com/authenticateKey/9f87004e
5. Sum of last digit of two given numbers :
https://tests.mettl.com/authenticateKey/783a1fcf
6. Is N an exact multiple of M?:
https://tests.mettl.com/authenticateKey/36c4ef58

7. Of given 5 numbers, how many are even?:


https://tests.mettl.com/authenticateKey/8edbe922

8. Of given 5 numbers, how many are odd?:


https://tests.mettl.com/authenticateKey/67147bd5

9. Of given 5 numbers, how many are even or odd?:


https://tests.mettl.com/authenticatekey/607636d7

Loops:

Learn to solve math based number problems (will require loops and maths)

10. Is Prime?: https://tests.mettl.com/authenticateKey/b1efaa3d

11. Factorial of a number: https://tests.mettl.com/authenticateKey/8c1f2ae

12. Nth Fibonacci: https://tests.mettl.com/authenticateKey/f390cadf

13. Nth Prime: https://tests.mettl.com/authenticateKey/34fdaa41

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

14. Number of Primes in a specified range:


https://tests.mettl.com/authenticateKey/87c41143

15. All Digits Count: https://tests.mettl.com/authenticateKey/ed6b4da

16. Unique Digits Count: https://tests.mettl.com/authenticateKey/b7aac4a5

17. Non-Repeated Digits’ Count:


https://tests.mettl.com/authenticateKey/e46500f5

Number Based:

18. digitSum: sum of all digits in N


https://tests.mettl.com/authenticateKey/ab1d60cc

19. digitSum even: sum of even digits in N


https://tests.mettl.com/authenticateKey/b55d1714

20. digitSum odd: sum of odd digits in N


https://tests.mettl.com/authenticateKey/738fdee0

21. digitSum opt: sum of even or odd digits


https://tests.mettl.com/authenticateKey/a05abbcf

22. Is Palindrome Number? https://tests.mettl.com/authenticateKey/28c41d9d

23. Is Palindrome Possible? https://tests.mettl.com/authenticateKey/f4fdb02

24. A number is said to be a magic number, if the sum of its digits are calculated till a
single digit recursively by adding the sum of the digits after every addition. If the
single digit comes out to be 1,then the number is a magic number.

for example-
Number= 50113
=> 5+0+1+1+3=10
=> 1+0=1
This is a Magic Number

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

For example-
Number= 1234
=> 1+2+3+4=10
=> 1+0=1
This is a Magic Number

25. 2 digit reduced subtracted form

Ex. 6928

6-9= 3

9-2=7

2- 8=6

O/p: 376

Not 2 digit num

Again perform RS

3-7=4

7-6=1

O/P:41

26. Program to print the sum of odd numbers and arrangement of odd sequence

I/P: 361589

Op:315968

27. Arrangement of odd sequence followed by even sequence

i/P:361589

o/p: 315968

28. Arrangement of odd sequence with count followed by even sequence with count

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

i/p:361589

o/p: 31594682

29. Program to reverse the number using a loop

Ex: 143

Output: 341

30. Problem to count the total number of odd and even in the given any digit number

Input = 53467

Ans:

Odd=3

Even=2

31. Problem to check whether all the numbers are arranged in ascending order

Input-1 = 4567

Output: Yes

Input-2 = 4576

Output: No

32. Stepping Number or Not

Neighbor number difference can be either -1 or 1

Input-1 = 12345

Output: Yes

Input-2 = 1245

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Output: No

33. Sum of Sums of Digits in Cyclic order:


https://tests.mettl.com/authenticateKey/1ddbe65e

34. Generate series and find Nth element:


https://tests.mettl.com/authenticateKey/d2272e10

35. Find result after alternate add_sub on N:


https://tests.mettl.com/authenticateKey/814effc3

36. Find Password (stable unstable):


https://tests.mettl.com/authenticateKey/5106dfd

37. Calculate sum of non-prime index values:


https://tests.mettl.com/authenticateKey/596e522f

38. Find the one digit to be removed to form palindrome:


https://tests.mettl.com/authenticateKey/6d825776

39. Create PIN using alpha, beta, gamma:


https://tests.mettl.com/authenticateKey/be582d9f

40. Weight of a hill pattern:


https://tests.mettl.com/authenticateKey/d612c0e6

Pattern Programs

41. No=5

11111

2 5

3 5

4 5

11111

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

42.

00

111

0000

11111

43.

no=5

12

123

1234

12345

44.

no=5

12

123

1234

12345

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

45.

no=5

12345

1234

123

12

46.

no=5

12345

2345

345

45

47.

no=5

12345

2345

345

45

48.

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

no=5

5 4 3 2 1

4 3 2 1

3 2 1

2 1

49.

no=5

10

101

1010

10101

50.

No-5

E D C B A

D C B A

C B A

B A

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

51.

No-5

E D C B A

A B C D

D C B

B A

52.
Print braces pattern program
int n=2
Output:
{}
{ } {{ }}

53.
Hour glass pattern
n=8

********
*******
******
*****
****
***
**
*
**
***
****
*****
******
*******

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

********

54.
Pyramid pattern

55.
Diamond pattern

Arrays
56. Missing number in an array of shuffled order
Input:[3, 7, 1, 2, 8, 4, 5]
Output:6
57. Second largest number in an array
Input:[12, 35, 1, 10, 34, 1]
Output:34
58. Re-arranged array by small – largest combination
Input: [1, 3, 5, 2, 8, 7, 4]
Output:[1, 8, 2, 7, 3, 5, 4]
59. Remove all duplicates in an array sample input and output
Input:[1, 2, 2, 3, 4, 4, 5]
Output:[1, 2, 3, 4, 5]

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

60. Frequency count with descending order printing

int a[] = { 50, 20, 150, 20, 50, 10, 30, 10, 10 };

61. Group Reverse

int a[] = { 10, 20, 30, 40, 50, 25, 35, 45 }; d=2

Expected OP: 30 20 10 45 35 25 50 40

62. Program to find the frequency count of every number in an array

Input={40,20,10,50,20,10,30,40}

Output:

40 -> 2

20 -> 2

10 -> 2

50 -> 1

30 -> 1

63. Program to find the frequency count of every number in an array in ascending
order

Input={40,20,10,50,20,10,30,40}

50->1

30->1

40->2

20->2

10->2

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

64. Program to find the frequency count of every number in an array in descending
order

Input={40,20,10,50,20,10,30,40}

40->2

20->2

10->2

50->1

30->1

65. Max contiguous Subarray


Input:[-2, 1, -3, 4, -1, 2, 1, -5, 4]
Output:6
Explanation:-2
-2,1
-2,3,-1 so on

66. Rotate an array by ‘N’ positions


Input:[1, 2, 3, 4, 5]
N=2
Output:[3, 4, 5, 1, 2]

67. Given an array of integers, return a new array such that each element at index i of
the new array is the product of all the numbers in the original array except the one
at i.
For example, if our input was [1, 2, 3, 4, 5], the expected output would be

[120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6]

68. Given an integer array find the duplicate element which has the longest distance

note: Assumed -1 as output if no duplicates are found

int arr[]={1,2,3,1,3,4,2,5,6,1};

O/p: 1

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

69. Given an integer array using searching element place the incremented number
next to searching number

Input = {10,20,10,30,14,40,60,10}

Search=10

Output={10,1,20,10,2,30,14,40,60,10,3}

70. Maximum subarray sum


Input: arr[] = {2, 3, -8, 7, -1, 2, 3}
Output: 11
Explanation: The subarray {7, -1, 2, 3} has the largest sum 11.

71. Minimum subarray sum


Input: A = [3, 1, 2, 4]
Output: 17
Explanation:
Subarrays are [3], [1], [2], [4], [3, 1], [1, 2], [2, 4], [3, 1, 2], [1, 2, 4], [3, 1, 2, 4].
Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1. Sum is 17.

72. Reverse an Array


Input: arr = [4, 5, 2]
Output: [2, 5, 4]
Explanation: The elements of the array are 4 5 2. The reversed array will be 2 5 4.

73. Finding Frequency of Duplicate elements in an array


Input : arr[] = {10, 20, 20, 10, 10, 20, 5, 20}

Output : 10 3

20 4

74. Finding frequency of Unique elements in an array


Input : arr[] = {10, 20, 20, 10, 10, 20, 5, 20}

Output : 5 1

75. Find distinct elements in an array

Input: arr[] = {12, 10, 9, 45, 2, 10, 10, 45}


Output: {12, 10, 9, 45, 2}

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Explanation:

Given an integer array arr[], print all distinct elements from this array. The given
array may contain duplicates and the output should contain every element only
once.

76. Insert an element in an array


Input: arr[] = [10, 20, 30, 40], pos = 3, ele = 50
Output: [10, 20, 50,30, 40]
77. Delete an element from an array
Input: arr[] = [10, 20, 30, 40], pos = 2
Output: [10, 30, 40]
78. Check if 2 Arrays are equal or not.
Input: a[] = [1, 2, 5, 4, 0], b[] = [2, 4, 5, 0, 1]
Output: true
79. Middle Element in an array.
Input: arr = {1, 2, 3, 4, 5}
Output: 3

Input: arr = {7, 8, 9, 10, 11, 12}


Output: 9 10

80. Leaders in an Array.


Input: arr[] = [16, 17, 4, 3, 5, 2]
Output: [17 5 2]
Explanation:
17 is greater than all the elements to its right i.e., [4, 3, 5, 2], therefore 17 is a
leader. 5 is greater than all the elements to its right i.e., [2], therefore 5 is a leader.
2 has no element to its right, therefore 2 is a leader.

81. Find common elements between 2 arrays.


Input : a[] = {1, 2, 1, 3, 1}, b[] = {3, 1, 3, 4, 1}
Output : {1, 3, 1}
82. Given an array of integers nums and an integer target, return indices of the two
numbers such that they add up to target.
Input: arr[] = [0, -1, 2, -3, 1], target = -2
Output: 3 4
Explanation: There is a pair (1, -3) with the sum equal to given target, 1 + (-3) = -2

83. Given an array nums of distinct integers, return all the possible permutations. You
can return the answer in any order.

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Input: nums = [1,2,3]

Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]

84. Given a 2D integer array matrix, return the transpose of the matrix.
Explanation:
The transpose of a matrix is the matrix flipped over its main diagonal, switching
the matrix's row and column indices.

Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]


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

85. Given an m x n matrix, return all elements of the matrix in spiral order.

Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]


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

86. Given three arrays A1, A2, A3. Find the count of the distinct values: A1 values
should not present in both A2 and A3. Similarly for A2 and A3
Input:[1, 2, 3, 4]
[3, 4, 5, 6]
[6, 7, 8]
Output:
87. Given an array of integers greater than zero, find if it is possible to split it in two
subarrays (without reordering the elements), such that the sum of the two
subarrays is the same. Print the two subarrays.

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Input: Arr[] = { 1 , 2 , 3 , 4 , 5 , 5 }
Output: { 1 2 3 4 }
{5,5}
88. Given an array of size N where the array elements contain values from 1 to N with
duplicates, the task is to find the total number of subarrays that start and end with
the same element.
Input: A[] = {1, 2, 1, 5, 2}
Output: 7
89. You are given an array arr, and your task is to find the majority element an element
that occurs more than half the length of the array (i.e., arr.size() / 2). If such an
element exists return it, otherwise return -1, indicating that no majority element is
present.
Input : arr[] = [1, 1, 2, 1, 3, 5, 1]
Output : 1

90. Given an array arr[] of size n and an integer k, the task is to insert a duplicate of k
adjacent to its every occurrence. Keep array's original length same by removing the
elements from the back.
Input: arr[] = [1, 0, 2, 3, 0, 4, 5, 0], K = 0
Output: [1, 0, 0, 2, 3, 0, 0, 4]
91. Given an array arr[], the task is to find the subarray that has the maximum sum and
return its sum.
Input: arr[] = {2, 3, -8, 7, -1, 2, 3}
Output: 11

92. Simple Encoded Array: https://tests.mettl.com/authenticateKey/1557c062

93. Decreasing sequence https://tests.mettl.com/authenticateKey/8e68e9a4

94. Most Frequently Occurring Digit:


https://tests.mettl.com/authenticateKey/cbe4c4da

95.

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

96. FIND KEY:

You are provided with 3 numbers input1,input2,input3.

Each of these are four digit numbers within the range >=1000 and <=9999

i.e

1000<=input1<=9999

1000<=input2<=9999

1000<=input3<=9999

you are expected to find the key using the below formula

Key=[smallest digit in the thousands place of all three numbers][LARGEST digit in


the hundreds place of all the three numbers]

[smallest digit in the tens place of all three numbers][LARGEST digit in the units
place of all three numbers]

for e.g if input1=3521,input2=2452,input3=1352,then Key=[1][5][2][2]=1522

Assuming that the 3 numbers are passed to the given function.Complete the
function to find and return the key.

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Strings
97. Validation of an Identifier
98. Total Number of Words in a given string
99. Adding the number from the String input

Input: 5ingt44t3

Output: 52

100. String Encoding

Input: aaaabbcccc

Output:a4b2c4

101. Highest frequency character in aString

Input: engineering

Output: e 3

102. Program to print the frequency count from highest to lowest

I/p: “repeatable”

O/p: e:3

a:2

r:1

p:1

t:1

b:1

l:1

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

103. Program to remove the palindromic string from the given input string

"In India Malayalam is best with dad and mom"

Output: "In India is best with and"

104. Program to count the characters which has lower followed by higher

Input="accept Van"

Output=2

105. Program to find the matching string and print it in Capitalcase

inp1="fi_er";

inp2="Fever:Filer:Filter:FIxer:Fiber:Fibre:Tailor:Offer";

106. Program to reverse either odd or even position based on the input

inp1="chennaicity"

inp2="odd"

Output:ctecnainihy

107. Program to process the string with unique characters count within the
distance

Input1=="my name is granar";

Input2='a';

Output=7

108. Program to encrypt the given string

input="aaabccccddaaaaab"

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

output=a3bc4d2a5b

109. Program to check the strings are anagram

"dogo"

"godo"

Output: true

110. Half of the string to lower case and remaining half to uppercase
I/P:”helloworld”
O/P:”helloWORLD”

111. Number of words present in the given sentences


Input:"The quick brown fox jumps over the lazy dog"
Output:9

112. Find the matching string and print it in Capitalcase


Input:"apple banana mango apple grape"
Matching word: "apple"
Output:"Apple banana mango Apple grape"

113. Reverse odd position based on the input


Input:"I love programming in python language"
Position to reverse: "odd"
Output: "I evol programming ni python egaugnal"

114. Split a string on hyphens


Input: Emma-is-a-data-scientist
Output:
Emma
Is
A
Data
Scientist

115. Longest palindrome substring


Input: = "babad"
Output: "bab”or "aba"

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

116. Longest substring without repeating characters


Input: s = “abcdefabcbb”
Output: 6
Explanation: The longest substring without repeating characters is “abcdef”.

117. First Non-Repeated character in a String


Input: s = "racecar"
Output: 'e'
Explanation: 'e' is the only character in the string which does not repeat.
118. First Repeated character in a string
Input : ababa
Output : a //in the 2nd index

119. Reverse sentence


Input: "Programming is fun"
Output: "fun is Programming"

120. Given a string s of lowercase English letters, the task is to find the first nn-
repeating character. If there is no such character, return '$'.

Input:"aabcdd"

Output:'b'

121. Check Whether Two Strings Are Anagram

Input1:listen

Input2:silent

Output:is anagram

122. Given a String, the task is to insert another string in between the given String
at a particular specified index in Java.

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Input:originalString = "WelcomeJava",

stringToBeInserted = "to",

index = 4

Output:"WelcometoJava"

123. Delete all the common elements of two string and concatenate both

a="aaaa"

b="aabbbb"

output:"bbbb"

124. Given a string of digits, remove leading zeros from it.


Input : 00000123569
Output: 123569

Input: 000012356090
Output: 12356090

125. print the highest frequency followed by lowest

Input:programming

Output:Highest frequency characters: r g m

Lowest frequency characters: p o a i n

126. decrypt the given string

Input:Encrypted string: khoor

Output:Decrypted string: hello

127. Identify possible words:


https://tests.mettl.com/authenticateKey/13486c16

128. Encoding Three Strings https://tests.mettl.com/authenticateKey/f05028d5

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

129. The “Nambiar Number” Generator


https://tests.mettl.com/authenticateKey/7db6c8a4

130. User ID Generation: https://tests.mettl.com/authenticateKey/592740f3

131. Message controlled Robot movement


https://tests.mettl.com/authenticateKey/aedcc3a6

132. Sum of Power of Digits:


https://tests.mettl.com/authenticateKey/92437794

133. User ID Generation: Joseph's team has been assigned the task of creating
user-ids for all participants of an online gaming competition Joseph has designed
a process for generating the user-d using the participant's First_Name ,Last_Name,
PIN code and a number N The process defined by Joseph is as
below –
Step1- Compare the lengths of First_Name and Last_Name of the participant. The
one that is shorter will be called “Smaller Name” and the one that is longer will be
called the “longer Name” if both First_Name and Last_Name are of equal Length
,then the name that appears earlier in alphabetical order will be called “Smaller
Name” and the name that appears later in alphabetical order will be
called the “Longer Name”
Step2 - The user-should be generated as below –
Last Letter of the smaller name + Entre word of the longer name + Digit at position
N in the PIN when traversing PIN from left to right +Digit at position N in the PIN
when traversing the PIN from right to left
Step3 - Toggle the alphabets of the user-id generated in step -2 i.e. upper-case
alphabets should become lower-case and lower-case alphabets should become
upper-case.
Let us see a few examples
Example-1 - If the participant's details are as below
First Name = Ray
Last Name =Roy
PIN = 560037
N= 6

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Step1 - Length of Last_Name is less than the Length of First_Name, so the Smaler
Name is “Roy” and the Longer Name is “Rajiv”
Step2 - The user id will be = Last Letter of the smaller name +Entre word in the
longer name + Digit at position N in the PIN when traversing the PIN from left to
right +Digit at position N in the PIN when traversing the PIN from right to left
=Last Letter of “Roy”+ Entre word in Rajiv+ 6th Digit of Pin from left + 6th Digit of
PIN from right
=y+ Rajiv+7+5
Therefore, user-id=yRajiv75
Step3 -Toggle the alphabet in the user-id. So,user-id = YrAJIV75

134. SIMPLE ENCODED ARRAY


Maya has stored few confidential numbers in an array (array of int). To ensure that
others do not find the numbers easily, she has applied a simple encoding.
Encoding used: Each array element has been substituted with a value that is the
difference of its original value and its succeeding element’s value.
i.e. arr[i] = arr[i+1]-arr[i]
e.g. value in arr[0] = original value of arr[1] - original value of arr[0]
Also note that value of last element i.e. arr[last index] remains unchanged.
Example:If the original array is –{2, 5, 1, 7, 9, 3}
The encoded array would be –{3, -4, 6, 2, -6, 3}
Provided the encoded array, you are expected to find the –
a) First number (value in index 0) in the original array
b) Sum of all numbers in the original array The prototype of the function is:public
static void findOriginalFirstAndSum(int[] input1,input 2);
where input1 is the encoded array.The method is expected to –
● find the value of the first number of the original array and store it in the member
output1 and
● find the sum of all numbers in the original array and store it in the member
output2.
Assumption(s):
● The array elements can be positive and/or negative numbers
Example 1:Original array = {2, 5, 1, 7, 9, 3} Encoded array = {3, -4, 6, 2, -6, 3} First
number in
original array = 2 Sum of all numbers in original array = 27

135. You’re given the size of the array and an array of integers; print the number
of times each integer has occurred in the array.

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Sample Input 1: 10
1233414512
Sample Output 1:
1 occurs 3 times
2 occurs 2 times
3 occurs 2 times
4 occurs 2 times
5 occurs 1 times

136. Write a method to find the number of longest increasing subsequences(LIS)


found in the given array and return the same.
• Longest Increasing Subsequence (LIS) finds the longest subsequence where
elements strictly increase in order.
• The LIS problem involves finding the longest subsequence of a sequence where
each element is greater than the previous one, preserving order.
int countOfLIS (int data []) {
//write code
}
Sample Input 1: 1 1 2 3 3 4 1 4 5 1 2
Sample Output 1: Number of longest increasing subsequences = 3
(Sub sequence 1: 1 1 2 3 3 4, sub sequence 2: 1 4 5, Sub sequence 3: 1 2)

137. Twin Prime. Difference between 2 numbers should be one


138. Find the Key:

input1=3521, input2=2452, input3=1352

Key= (Thousands of input1*Hundreds of input2) + smallest of input3

Key= (3*4) +1=13

139. Find the Key:

input1=3521, input2=2452, input3=1352

Key= (Smallest digit in thousands Place) (Smallest digit in hundreds Place)


(Smallest digit in tens Place) (Smallest digit in units Place)

Key=1321

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

140. Find the Key:

You are provided with 3 numbers: input1, input2 and input3. Each of these
are 4 digits’ numbers within >=1000 and <=9999 i.e., 1000<=input1<=9999
1000<=input2<=9999 1000<=input3<=9999 You are expected to find the key using
below formula:

Key = Sum of Largest digits of each number + Sum of Second Largest digits of each
number for Example, input1=3521, input2=2452 input3=1352

Key = (5+5+5) + (3+4+3) = 25

141. Sum of the numbers upto a single digit

Input1 = 45678

Output = 30 (double digit)

= 3 (i.e 3+0)

142. Ranking

Given the array of elements where you have to print the rank of every
elements in the array without changing the position

Input:

{10,5,20,30,1,4,25}

Output:

4, 3, 5, 7, 1, 2,6

143. Find Password

Detective Buckshee junior has been approached by the shantiniketan kids society
for help in finding the password to the games complex.After hearing the

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

scenario,detective Buckshee junior realises that he will need a programmer's


support.He contacts you requests your help.

Please help the detective by writing a function to generate the password.

The scenario is as below-

Five numbers are available with the kids.

These numbers are either stable or unstable

A number is stable if each of its digit occur the same number of times, i.e the
frequency of each digit in the number is the same.

For e.g:2277,4004,11,23,583835,1010 are examples of stable numbers.

Similarily,A number is unstable if the frequency of each digit in the number is NOT
the same.For eg:221,4314,101,233,58135,101 are examples of unstable numbers.

The password can be found as below-

i.e password=(Number of unstable numbers*10)+Number of stable numbers

For example:

If input1=12, input2=1313, input3=122, input4=678 and input5=898 , we see that


there are THREE stable numbers i.e 12,1313 and 678 and

TWO unstable numbers i.e 122 and 898

so,the password should be=(Number of Unstable numbers*10)+Number of stable


numbers=(2*10)+3=23

144. Find the Key:

input1=3521, input2=2452, input3=1352

Key= Smallest number from input1+ Smallest number from input2+ Smallest
number from input3+ largest number from input1+ largest number from input2+
largest number from input3

Key=1+2+1+5+5+5=19

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

145. Remove duplicate elements from an array

Given an array of integers, we have to remove duplicate elements using a java


program.

Input array elements:

1, 2, 3, 1, 2, 3, 4

Output:

Elements after removing duplicates

1, 2, 3, 4

146. Find second largest element in an array

Given an array of N integers and we have to find its second largest element using
Java program.

Input:

Enter number of elements: 4

Input elements: 45, 25, 69, 40

Output:

Second largest element in: 45

147. Find second smallest element in an array

Given an array of N integers and we have to find its second minimum/smallest


element using Java program.

Input:

Enter number of elements: 4

Input elements: 45, 25, 69, 40

Output:

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

Second smallest element in: 40

148. Count total positives, negatives and zeros from an array

Given an array of integers and we have to count total negatives, positives and zeros
using java program.

Input:

Array elements: 20, -10, 15, 00, -85

Output:

Positive Numbers are: 2

Negative Numbers are: 2

Zeros are: 1

149. Given an integer array of size N. Write Program to find sum of positive square
elements in the array.

Sample input 1:

1234

Sample output 1:

30

Explanation :

(1 + 4 + 9 + 16) = 30

Sample input 2:

-1 -2 -3 -4

Sample output 2:

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)
VEL TECH HIGH TECH
Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE
An Autonomous Institution
Approved by AICTE - New Delhi, Affiliated to Anna University - Chennai
Accredited by NBA, New Delhi & Accredited by NAAC with "A" grade & CGPA of 3.27

30

Explanation:

(1 + 4 + 9 + 16) = 30

150. Given an integer array of size N, write a program to sort the array;

Sample input 1:
4
2413
Sample output 1:
1234
Sample input 2:
5
15753
Sample output 2:
13557

With reference to NBA – SAR Guideline: Criteria No. 4.5 & 7.3(a)

You might also like