JIRA
JIRA
Without using reverse string instead here we can use swapping method
Once done with each character swapping then we can see reverse string i.e., “dlroW olleH”
Palindrome
Here take a string “madam”
From left side to right side & right side to left side
#include <stdio.h>
void reverse_array(int arr[], int size) {
int left = 0;
int right = size - 1;
int main() {
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
int size = sizeof(arr) / sizeof(arr[0]);
return 0;
}
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
int size = sizeof(arr) / sizeof(arr[0]);
int n = 2;
printf("Original array: ");
for (int i = 0; i < size; i++) {
printf("%d ", arr[i]);
}
printf("\n");
rotate_array(arr, size, n);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main() {
int arr[] = {1, 2, 3, 4, 5, 6};
int *flatten_result = NULL;
int flatten_size = 0;
flatten_array(arr, 6, &flatten_result, &flatten_size);
printf("Flattened array: [");
for (int i = 0; i < flatten_size; i++) {
printf("%d", flatten_result[i]);
if (i < flatten_size - 1) {
printf(", ");
}
}
printf("]\n");
free(flatten_result);
return 0;
}
1)Given an array of distinct integers, find all the pairs having positive value and
negative value of a number that exists in the array. Return the pairs in any
order.
Note: The pair consists of equal absolute values, one being positive and another
negative.
Return an empty array, if no such pair exists.
Input: 4 8 9 -4 1 -1 -8 -9
Output: [-1 ,1, -4, 4, -8, 8, -9, 9]
import java.util.*;
}
}
import java.io.*;
class fib {
static void Fibonacci(int N)
{
int num1 = 0, num2 = 1;
for (int i = 0; i < N; i++) {
System.out.print(num1 + " ");
int num3 = num2 + num1;
num1 = num2;
num2 = num3;
}
}
public static void main(String args[])
{
int N = 8;
Fibonacci(N);
}
}