Lecture 2- Competitive Programming- Problem Statement 1

Krish Naik · Intermediate ·⚡ Algorithms & Data Structures ·6y ago

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 Natural Language Processing|Stemming
Natural Language Processing|Stemming
Krish Naik
2 Natural Language Processing|BagofWords
Natural Language Processing|BagofWords
Krish Naik
3 Gaussian distribution or Normal Distribution in statisctics
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
4 Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
5 Log Normal Distribution in Statistics
Log Normal Distribution in Statistics
Krish Naik
6 Covariance in Statistics
Covariance in Statistics
Krish Naik
7 Confusion matrix, Precision, Recall| Data Science Interview questions
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
8 Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
9 Implementing a Spam classifier in python| Natural Language Processing
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
10 Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
11 Face Recognition using open CV and VGG 16 Transfer Learning
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
12 Pedestrian Detection using OpenCV from Videos
Pedestrian Detection using OpenCV from Videos
Krish Naik
13 Face and Eye Detection from Videos using HAAR Cascade Classifier
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
14 Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
15 OpenCV Installation | OpenCV tutorial
OpenCV Installation | OpenCV tutorial
Krish Naik
16 Face and Eye Detection from Images using HAAR Cascade Classifier
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
17 Car Detection using HAAR Cascade and Opencv from Videos.
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
18 Using OpenFace for Face recognition in Keras
Using OpenFace for Face recognition in Keras
Krish Naik
19 OpenPose Tutorial with Tensorflow
OpenPose Tutorial with Tensorflow
Krish Naik
20 Multiple Linear Regression using python and sklearn
Multiple Linear Regression using python and sklearn
Krish Naik
21 Dimensional Reduction| Principal Component Analysis
Dimensional Reduction| Principal Component Analysis
Krish Naik
22 Movie Recommender System using Python
Movie Recommender System using Python
Krish Naik
23 TPR,FPR,FNR,TNR, Confusion Matrix
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
24 Precision, Recall and F1-Score
Precision, Recall and F1-Score
Krish Naik
25 Artificial Neural Network for Customer's Exit Prediction from Bank
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
26 GridSearchCV- Select the best hyperparameter for any Classification Model
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
27 RandomizedSearchCV- Select the best hyperparameter for any Classification Model
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
28 K Nearest Neighbor classification with Intuition and practical solution
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
29 K Means Clustering Intuition
K Means Clustering Intuition
Krish Naik
30 Create custom Alexa Skill- Lambda function- Part2
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
31 Hierarchical Clustering intuition
Hierarchical Clustering intuition
Krish Naik
32 Implement Transfer Learning with a generic Code Template
Implement Transfer Learning with a generic Code Template
Krish Naik
33 Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
34 Unlock Your Application With Your Face using OpenCV
Unlock Your Application With Your Face using OpenCV
Krish Naik
35 Draw rectangle from webcam and sketch process it on a live feed
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
36 Complete Life Cycle of a Data Science Project
Complete Life Cycle of a Data Science Project
Krish Naik
37 How we can apply Machine Learning in Finance
How we can apply Machine Learning in Finance
Krish Naik
38 Deep Learning in Medical Science
Deep Learning in Medical Science
Krish Naik
39 How to switch your career to Data Science.
How to switch your career to Data Science.
Krish Naik
40 Linear Regression Mathematical Intuition
Linear Regression Mathematical Intuition
Krish Naik
41 Handle Categorical features using Python
Handle Categorical features using Python
Krish Naik
42 Machine Learning Algorithm- Which one to choose for your Problem?
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
43 DBSCAN Clustering Easily Explained with Implementation
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
44 Curse of Dimensionality Easily explained| Machine Learning
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
45 Feature Selection Techniques Easily Explained | Machine Learning
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
46 Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
47 Cross Validation using sklearn and python | Machine Learning
Cross Validation using sklearn and python | Machine Learning
Krish Naik
48 Handling Missing Data Easily Explained| Machine Learning
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
49 Deploy Machine Learning Model using Flask
Deploy Machine Learning Model using Flask
Krish Naik
50 Deployment of Deep Learning Model using Flask
Deployment of Deep Learning Model using Flask
Krish Naik
51 How to Visualize Multiple Linear Regression in python
How to Visualize Multiple Linear Regression in python
Krish Naik
52 K Nearest Neighbour Easily Explained with Implementation
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
53 Predicting Heart Disease using Machine Learning
Predicting Heart Disease using Machine Learning
Krish Naik
54 Predicting Lungs Disease using Deep Learning
Predicting Lungs Disease using Deep Learning
Krish Naik
55 Stock Sentiment Analysis using News Headlines
Stock Sentiment Analysis using News Headlines
Krish Naik
56 Random Forest(Bootstrap Aggregation) Easily Explained
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
57 Voting Classifier(Hard Voting and Soft Voting Classifier)
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
58 Credit Card Fraud Detection using Machine Learning from Kaggle
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
59 Hyperparameter Optimization for Xgboost
Hyperparameter Optimization for Xgboost
Krish Naik
60 Tutorial 45-Handling imbalanced Dataset  using python- Part 1
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik

Related Reads

📰
The Minecraft anvil is a tree-cost optimization problem in disguise
Optimize tree costs in Minecraft using graph theory and algorithms, just like the anvil repair system
Dev.to · Mark
📰
KMP Algorithm (Knuth-Morris-Pratt): The Smart Way to Perform String Matching in O(N)
Learn the KMP algorithm for efficient string matching in O(N) time complexity and improve your coding skills
Dev.to · Jaspreet singh
📰
Every Backtracking Problem Is the Same Three Lines. I Just Couldn't See the Tree.
Master backtracking problems with a simple three-line approach to improve problem-solving skills in coding interviews and challenges
Dev.to · Alex Mateo
📰
DSA From Zero to Hero #3: Sliding Window (Fixed Size) Explained With a Java Example
Learn to solve subarray problems efficiently using the sliding window technique, a crucial skill for software engineers and data scientists
Medium · Programming
Up next
Stump Grinder Carbide Wheel Grinds Hardwood To Chips
Innoforge Studio
Watch →