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
print(eval(input("")))
2🔥21👏1👀1
CᴏᴅɪɴɢNᴇʀᴅ 💸🐾
Question 5 : Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1, 2, 3, 1] Output: true Example 2: Input: nums = [1, 2, 3, 4] Output: false…
#include <stdio.h>

int check_dual_int(int arr[], int length) {
for (int i = 0; i < length; i++) {
for(int j=i+1; j< length; j++) {
if(arr[i] == arr[j]) {
return 1;
}
}
}
return 0;
}

int main() {
int arr[] = {1, 2, 3, 1};
int length = sizeof(arr) / sizeof(arr[0]);

if(check_dual_int(arr, length) == 1) {
printf("True");
} else {
printf("False");
};
return 0;
}
🔥2👾2👍1
print(f"{"Boom":_^20}")
👾32👨‍💻2🔥1
Day 01 👾:
Given an array of positive integers arr[] of size n, the task is to find second largest distinct element in the array.
Note: If the second largest element does not exist,
return -1.
👨‍💻2👍1🔥1👾1
Day 02 👾:
Given an array of integers arr[], the task is to move all the zeros to the end of the array while maintaining the relative order of all non-zero elements.
👏3🔥21
Day 03 👾:
Given an array arr[], the task is to reverse the array. Reversing an array means rearranging the elements such that the first element becomes the last, the second element becomes second last and so on.
🔥21👏1👨‍💻1
Day 04 👾:
Given an array of integers arr[] of size n, the task is to rotate the array elements to the left by d positions.
🔥2🕊2👏1
Day 05 👾:
Given an array arr[] of size n, the task is to print the lexicographically next greater permutation of the given array. If there does not exist any greater permutation, then find the lexicographically smallest permutation of the given array.

Let us understand the problem better by writing all permutations of
[1, 2, 4] in lexicographical order

[1, 2, 4], [1, 4, 2], [2, 1, 4], [2, 4, 1], [4, 1, 2] and [4, 2, 1]

If we give any of the above (except the last) as input, we need to find the next one in sequence. If we give last as input, we need to return the first one.
🔥2👨‍💻21
F-strings usage and formats in Python!

Code Examples:

1. Basic F-string:
name = "Chiku"
age = 21
print(f"Name: {name}, Age: {age}")
# Use code and learn.



2. Debugging:
var = 100
print(f"var={var}")
print(f"{var = }")
# Use code and learn.



3. Rounding:
decimal_number = 1234.5678
percent = 0.5678
print(f"Decimal: {decimal_number:.2f}")
print(f"Percent: {percent:.2%}")
# Use code and learn.



4. Thousands separators:
big_number = 1000000
print(f"Big number: {big_number:,}")
# Use code and learn.



5. Date and time formatting:
import datetime
now = datetime.datetime.now()
print(f"Date: {now:%x}")
print(f"Date and time: {now:%c}")
print(f"Time: {now:%H:%M:%S}")
# Use code and learn.



6. Raw strings:
path = fr"C:\Users\{user}\Documents"
# Use code and learn.
# Do not use in big project, use this format for fun only



7. Alignment:
text = "Chiku"
print(f"{text:>20}") # Right align
print(f"{text:^20}") # Center align
print(f"{text:<20}") # Left align
# Use code and learn.



8. Custom F-string class:
class Text:
def __init__(self, text):
self.text = text

def __format__(self, format_spec):
if format_spec == "upper":
return self.text.upper()
elif format_spec == "lower":
return self.text.lower()
elif format_spec == "count":
return str(len(self.text))
else:
raise ValueError(f"Invalid format specifier: {format_spec}")

text = Text("Chiku")
print(f"{text:upper}")
print(f"{text:lower}")
print(f"{text:count}")
# Use code and learn.
3🔥3
Day 06 👾:
Given an array arr[] consisting of n integers, the task is to find all the array elements which occurs more than floor(n/3) times.

Note: The returned array of majority elements should be sorted.
🔥3👏3
Creating Virtual Environment for Python

» Download Python
First you need python installed in your local machine to create virtual environment.
Download Python from Here



» Steps to create '.env' folder (virtual environment for python)
1. Navigate to the folder where you want to make your project
Example:

cd D:/code/


2. Open terminal (local terminal, command prompt, or vs code terminal) in that folder

3. Now, use these commands
python --version # Type this and hit enter to verify the python version


# Now use these commands
python -m venv .env


4. Your virtual environment is created in that folder, now activate this virtual environment using this command.

Command for 'Command Prompt':
.\env\Scripts\activate


Command for 'Powershell':
.\env\Scripts\Activate.ps1


Command for Git Bash or WSL:
source \.env\bin\activate


If Powershell gives you error like File cannot be loaded because running scripts is disabled then use this command!
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass


5. Congratulations🎊 Your virtual environment activated now make your project


Happy Coding 👨‍💻
🐳31👍1🕊1
Day 07 👾:
Q. Stock Buy and Sell - Multiple Transaction Allowed (Hard)

Given an array prices[] of size n denoting the cost of stock on each day, the task is to find the maximum total profit if we can buy and sell the stocks any number of times.

Note: We can only sell a stock which we have bought earlier and we cannot hold multiple stocks on any day.
3🔥3
Day 08👾:
Given an array prices[] of length n, representing the prices of the stocks on different days. The task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell. If it is not possible to make a profit then return 0.

Note: Stock must be bought before being sold.
👍2🐳2👏1🕊1
» Image Captcha Generator 👨‍💻

Let's make a image captcha generator using python.
You can use it in your website or in telegram bots for user verifications, it generate random text in image so that bots can be recognize..


1. At first create virtual environment for your project (This is more convenient when you building a project, it provides an isolated space from your default local machine's python interpreter.

If you don't know how to make virtual environment, Follow This Post


2. Now let's install libraries that we need
pip install captcha pillow


3. Let't Write code for our image captcha
from captcha.image import ImageCaptcha
from io import BytesIO
from PIL import Image
import string, random

def random_text():
text = string.ascii_letters + string.digits
f_text = ''
for i in range(6):
f_text += random.choice(text)
return f_text

def image_captcha(text: str) -> None:
captcha: ImageCaptcha = ImageCaptcha(width=400, height=200, font_sizes=(50, 70, 100))

data: BytesIO = captcha.generate(text)
image: Image = Image.open(data)
image.show('Temp')


if __name__ == '__main__':
image_captcha(random_text())


Run Code and test yourself

@NotCoding | @CodesSnippet

Happy Coding 👨‍💻
🔥2👏21🐳1
Sample image of captcha generator code
👏2🐳2🔥1
Day 09👾:
Given the heights of n towers and a positive integer k, increase or decrease the height of all towers by k (only once). After modifications, the task is to find the minimum difference between the heights of the tallest and the shortest tower.
🔥4👍2
Day 10👾:
Given an array arr[], the task is to find the subarray that has the maximum sum and return its sum.
👏3🔥2
Day 11👾:
Given an array arr[] that contains positive and negative integers (may contain 0 as well). Find the maximum product that we can get in a subarray of arr[].

Note: It is guaranteed that the output fits in a 32-bit integer.
🔥32👍1
Day 12👾:
Given an array of integers arr[] in a circular fashion. Find the maximum subarray sum that we can get if we assume the array to be circular.
👍3🔥1👏1💋1
° Setup and install Tailwindcss °

→ To setup and install Tailwindcss in your local machine (pc), you need to follow some steps!!


→ At first to install Tailwindcss you need nodejs installed in your pc, let's intsall nodejs first..
› To install nodejs visit official website of nodejs, download latest version and install it simply by running that executable file.

› If you have Mac or linux then go to Official website and choose nodejs for your machine.

> Verify installation by running command: node -v


→ Now node is installed in your pc now we will install Tailwindcss, follow the steps
1. Go to folder where you want to make your project. (You can also install it directly by terminal.)
Example:
cd D:/code/ 


2. Right-click and open in terminal or open that folder in vs code and open terminal there.

3. Install Tailwindcss.
npm install -D tailwindcss


4. Initalize Tailwind for your project (run this command in that directory where you want to setup and develop your project).
npx tailwindcss init


5. You will see tailwind.config.js named file is created, you need to edit it. Open that file you will see some code (keep it for now let's create some folder first).

6. Create 2 folders named dist and src, in src folder create a file named input.css and write this code in this file.
@tailwind base;
@tailwind components;
@tailwind utilities;


7. And in dist folder your all project file will placed make their index.html and style.css.
8. Now edit that tailwind.config.js mentioned in step 5. Edit Content property in this file.
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./dist/*.html"],
theme: {
extend: {},
},
plugins: [],
}


9. Now run this code in terminal (This will work as live server for tailwindcss).
npx tailwindcss -i ./src/input.css -o ./dist/style.css --watch


10. Now Tailwindcss installed and now u can write your html code. You don't need to edit style.css just write code in html file. For more visit official website of tailwindcss and read docs.

@NotCoding | @CodesSnippet

Happy Coding 👨‍💻
🔥211👍1👏1