Solution :
check_palindrome
lower_
_string
string
_lower()
Let stack = new Stack()
Let queue = new Queue();
for each character c in lower_case_string:
stack.push(c);
queue.enqueue(c);
let isPalindrome = true;
while queue is not empty {
if (queue.remove().equals(stack.pop())) {
continue;
} else {
isPalindrome=false;
break while loop;
}
}
return isPalindrome
Input = aabb
output = true
input =abcd
output = false
There are several topics that you shouldn't bring up during an interview of any sort.
Answer:
<u>for loop code:</u>
int total=0;
for(int i=0;i<10;i++)
{
total + = value[i];
}
Explanation:
By declaration we know that the array is of size 10 which means the index will start from 0.
The variable name to be used to store the sum is given as total
We will initialize total with zero so that no garbage value is used.
For loop will be used to access the elements of array and calculate the sum. The syntax of for loop is given as:
for (initialization; condition; increment/decrement)
{statement}
<u>Code:</u>
int total=0;
for(int i=0;i<10;i++)
{
total + = value[i];
}