Lecture 2- Competitive Programming- Problem Statement 1
Skills:
Algorithm Basics80%
Key Takeaways
Solves a competitive programming problem using sorting and logic
Full Transcript
hello my name is Krishna and welcome to my youtube channel so guys I had given you a problem stated in my previous video regarding data structures and algorithms and that particular problem statement I had not completely defined so now I'll give you an idea about competitive programming and this will be the first problem statement I know we have not completed data structures and algorithms for solving this particular problem statement you don't require any data structures and algorithms as such because simple logic of code you know you'll be able to actually solve this particular problem and don't worry don't worry about the time constraint it is taking don't worry about anything that how much time it is taking or how much memory complexity or memory storage space complicity is actually digging up so make sure that you try to solve this search in the internet try to search something so that you'll be able to understand okay now always remember guys whenever you're building logic just go line by line to understand this particular problem statement now I am going to give you this particular problem and remember this particular problem statement is the interview question from top notch called top notch product based companies like Ola uber Facebook Amazon Google so this kind of questions I'll be taking it up and I'll be presenting it in front of you so I'm reading down this particular question and this question will be put up in the description for your reference purpose now suppose we have an array of n integers so total n integers I have it can be any value where every element is from the range suppose every element is from the range thousand to four nines okay then the task is to make the array non decreasing by changing only one digit okay so what does this basically means suppose if I have an example as on my input suppose my input looks something like this one zero nine five one zero nine four one zero nine five now suppose in this particular case I don't consider in what order this particular input is I don't consider okay I don't have to worry about it but my output should be in a non decreasing order now here you can see that this this this may be an ascending or descending order it is fine but my output should be in the form of an ax order or non-decreasing order and I should be only able to change one bit okay I should be able to change only one bit one bit in this particular array only one digit in this particular array and try to make this ISM in an ascending order or you can see say in a non decreasing way okay non decreasing order so here if I take this particular example remember this first element should become the smallest element if I am applying this particular logic so suppose if I convert this nine to zero this will become 1 0 0 5 now what about my next element in my next element what I do is that I will try to again take this 9 and always remember this number should be greater than this if I make it as 0 4 this will be smaller number so what is the next number that I can do I can actually change this 9 to 1 okay now similarly what about this what about this particular number right now for changing this particular number I can basically write it as 2 5 or I can also write it as 1 5 I can also write it as 1 v 1 v 2 v both will match now here you can see that here is in that ascending order and what I have done I have just changed one bit and converted to this again guys this is just a problem statement tomorrow I will be discussing the solution for this for for you all how we can actually solve it and remember I will also show you how to actually code it in Python okay okay guys let me take another problem statement suppose my input is suppose my input is this many files this many force this many trees this many twos and this many ones ok now I should be able to write a problem statement our code in such a way that remember I should be able to convert this like how I have actually converted into this right so I have to basically write a generic code now in this particular scenario over here you can see my input is in descending order you know from largest to smallest now suppose if I want to find out the output by applying the same logic the output looks should look something like this this 5 I will try to convert this into 1 now this will become the smallest element okay now similarly if I try to convert this number this 4 will get cut - right now remember this is greater than this that is properly exactly fine you know now what about this particular number this number I can take it directly also right I can take it directly I can take this lightly because this number is greater than this particular number but understand if I take it directly what about this numbers and this number that also we need to have a look you need to take that thing into consideration so in order to convert this what I'll do is that I'll make this as 3 0 3 3 and remember whatever next number I am choosing it should be at least some difference should be there not a huge difference because it will be difficult for this particular numbers to actually change in that order then okay then what about this one for this one what I can do is that I can just convert this to 2 3 and this will become my food 3 tripled oh right then similarly I can convert this one to 4 and then this will become like this remember in this particular problem statement you can change any digit from that particular element so you have to think of this particular logic guys this is what is competitive programming I know you know how to code but writing the logic considering the time constraint considering them you know space complexity it is pretty much important so again this is just a problem statement guys try try your level best like how ever you can I don't have to you don't have to worry about time complexity or space complexity just try to write down whatever you can and tomorrow I will be coming up with this particular solution I'll be showing you the pseudocode and I'll also help you to write the Python programming language so yes this was all about this particular video I hope you liked it please do subscribe the channel if you have not already subscribe see you in the next video have a great day thank you one and all bye-bye
Original Description
Problem Statement
Suppose you have an array within the range of [1000,9999]. The main aim is to change the numbers in ascending order by changing one digit from every array element.
Input: arr[] = {5555, 4444, 3333, 2222, 1111}
Output: 1555 2444 3033 3222 4111
Please join as a member in my channel to get additional benefits like materials in Data Science, live streaming for Members and many more
https://www.youtube.com/channel/UCNU_lfiiWBdtULKOw6X0Dig/join
Please do subscribe my other channel too
https://www.youtube.com/channel/UCjWY5hREA6FFYrthD0rZNIw
Connect with me here:
Twitter: https://twitter.com/Krishnaik06
Facebook: https://www.facebook.com/krishnaik06
instagram: https://www.instagram.com/krishnaik06
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Krish Naik · Krish Naik · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Natural Language Processing|Stemming
Krish Naik
Natural Language Processing|BagofWords
Krish Naik
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
Log Normal Distribution in Statistics
Krish Naik
Covariance in Statistics
Krish Naik
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
Pedestrian Detection using OpenCV from Videos
Krish Naik
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
OpenCV Installation | OpenCV tutorial
Krish Naik
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
Using OpenFace for Face recognition in Keras
Krish Naik
OpenPose Tutorial with Tensorflow
Krish Naik
Multiple Linear Regression using python and sklearn
Krish Naik
Dimensional Reduction| Principal Component Analysis
Krish Naik
Movie Recommender System using Python
Krish Naik
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
Precision, Recall and F1-Score
Krish Naik
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
K Means Clustering Intuition
Krish Naik
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
Hierarchical Clustering intuition
Krish Naik
Implement Transfer Learning with a generic Code Template
Krish Naik
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
Unlock Your Application With Your Face using OpenCV
Krish Naik
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
Complete Life Cycle of a Data Science Project
Krish Naik
How we can apply Machine Learning in Finance
Krish Naik
Deep Learning in Medical Science
Krish Naik
How to switch your career to Data Science.
Krish Naik
Linear Regression Mathematical Intuition
Krish Naik
Handle Categorical features using Python
Krish Naik
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
Cross Validation using sklearn and python | Machine Learning
Krish Naik
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
Deploy Machine Learning Model using Flask
Krish Naik
Deployment of Deep Learning Model using Flask
Krish Naik
How to Visualize Multiple Linear Regression in python
Krish Naik
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
Predicting Heart Disease using Machine Learning
Krish Naik
Predicting Lungs Disease using Deep Learning
Krish Naik
Stock Sentiment Analysis using News Headlines
Krish Naik
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
Hyperparameter Optimization for Xgboost
Krish Naik
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik
More on: Algorithm Basics
View skill →Related Reads
📰
📰
📰
📰
The Minecraft anvil is a tree-cost optimization problem in disguise
Dev.to · Mark
KMP Algorithm (Knuth-Morris-Pratt): The Smart Way to Perform String Matching in O(N)
Dev.to · Jaspreet singh
Every Backtracking Problem Is the Same Three Lines. I Just Couldn't See the Tree.
Dev.to · Alex Mateo
DSA From Zero to Hero #3: Sliding Window (Fixed Size) Explained With a Java Example
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI