CᴏᴅɪɴɢNᴇʀᴅ 💸🐾
99 subscribers
118 photos
3 videos
15 files
40 links
༗ हरे कृष्णा ༗
"Lost in my own cosmos 💫 | Coding Need Patience 🥀🐾"

❝Face the failure, Until the Failure fails to face you.❞

— Dreamer

» ChikuX69.netlify.app «

DM ? " @ChikuXBot " : 404;
Download Telegram
Question 6 Solution »

// bubble shorting
public class BubbleShort {
public static void bubbleShort(int[] arr) {
// outer loop
for(int i=0; i<arr.length; i++) {
// inner loop
for(int j=i+1; j<arr.length; j++) {
if(arr[i] > arr[j]) {
arr[i] = arr[i] + arr[j];
arr[j] = arr[i] - arr[j];
arr[i] = arr[i] - arr[j];
}
}
}
}
public static void main(String[] arg) {
int[] array = {5, 4, 1, 3, 2};
bubbleShort(array);
for(int i=0; i<array.length; i++) {
System.out.print(array[i] + " ");
}
}
}
Question 6 Solution »

// bubble short
#include <iostream>
using namespace std;

void bubble(int array[], int N) {
// outer loop
for(int i=0; i<N-1; i++) {
// inner loop
for(int j=i+1; j<N; j++) {
if(array[i] > array[j]) {
array[i] = array[i] + array[j];
array[j] = array[i] - array[j];
array[i] = array[i] - array[j];
}
}
}
}

int main() {
int arr[5] = {5, 4, 1, 3, 2};
int N = 5;
bubble(arr, N);
for(int i=0; i<N; i++) {
cout << arr[i] << " ";
}
return 0;
}
Standard: Easy
Output of ( 2 << 1 ) is
Anonymous Quiz
18%
1
29%
2
24%
3
29%
4
👍21
// identifying odd or even number

import java.util.Scanner;
public class IsOddEven {
public static void isOddEven(int num) {
if((num & 1) == 1) {
System.out.print(num + " is odd number");
} else {
System.out.print(num + " is even number");
}
}
public static void main(String[] arg) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number : ");
int number = sc.nextInt();
isOddEven(number);
}
}
1
# check number given by user is even or odd

def is_odd_even(num):
if (num & 1) == 1:
print(f"{num} is a odd number.")
else:
print(f"{num} is an even number.")


print(is_odd_even(int(input("Enter a number: "))))
1
Black Day for us 🖤🕯🕯
1😢1🫡1🤪1
// Recursion logic : Factorial of N numbers...

public static int fact(int num) {
if(num == 1) {
return 1;
} else {
return num * fact(num - 1);
}
}
👍1
// Removing duplicate characters from string...

public class DuplicateString {
public static void removeDuplicate(String str, int idx, StringBuilder newStr, boolean[] map) {
if(idx == str.length()) {
System.out.print(newStr);
return;
}
char chr = str.charAt(idx);
if (map[chr - 'a'] == true) {
removeDuplicate(str, idx+1, newStr, map);
} else {
map[chr - 'a'] = true;
removeDuplicate(str, idx+1, newStr.append(chr), map);
}
}
public static void main(String[] args) {
String str = "hello";
removeDuplicate(str, 0, new StringBuilder(""), new boolean[26]);
}
}
👍1
» Question 7..

int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
int* res = (int*)malloc(2 * sizeof(int));
*returnSize = 2;
for(int i=0; i<numsSize-1; i++) {
for(int j=i+1; j<numsSize; j++) {
if(nums[i] + nums[j] == target) {
res[0] = i;
res[1] = j;
return res;
}
}
}
return res;
};
Question 7..

class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
std::vector<int> res;
for(int i=0; i<nums.size()-1; i++) {
for(int j=i+1; j<nums.size(); j++) {
if(nums[i] + nums[j] == target) {
res.push_back(i);
res.push_back(j);
return res;
}
}
}
return res;
}
};
Question 7..

public int[] twoSum(int[] nums, int target) {
for(int i=0; i<nums.length-1; i++) {
for(int j=i+1; j<nums.length; j++) {
if(nums[i] + nums[j] == target) {
return new int[]{i, j};
}
}
}
return new int[]{};
}
Question 7..

def twoSum(self, nums, target):
for i in range(len(nums)-1):
for j in range(i+1, len(nums)):
if nums[i] + nums[j] == target:
return [i, j]
return []
Question 7..

var twoSum = function(nums, target) {
for(let i=0; i<nums.length-1; i++) {
for(let j=i+1; j<nums.length; j++) {
if(nums[i] + nums[j] == target) {
return [i, j];
}
}
}
return []
};
image_2024-02-24_03-12-59.png
41.1 KB
Little Bit Unexpected 😂

Question:
Here
// Checking input is palindrome or not 
// Example: 121 is palindrome number

function isPalindrome(num) {
const original = num;
let reminder = 0;
while(num != 0) {
let lastDig = num % 10;
reminder = (reminder * 10) + lastDig;
num = Math.floor(num / 10);
}
return original === reminder;
};

const userInput = parseInt(prompt("Enter a number: "));

if(isPalindrome(userInput)) {
console.log(`${userInput} is Palindrome.`);
} else {
console.log(`${userInput} is not Palindrome.`)
}



Approx Time: 0.240966796875 ms
Which language is considered as fasted programming language ??
Anonymous Quiz
19%
Java
19%
JavaScript
48%
C
14%
Python
Doubly.png
147.2 KB
🧐🧐
👍21🥴1😨1
Ah Bro👀🙄
👍1🌚1😐1