- Lecture: 1 Homework Solutions
- Lecture: 2 Homework Solutions
- Lecture: 3 Homework Solutions
- Lecture: 4 Homework Solutions
- Lecture: 5 Homework Solutions
- Lecture: 6 Homework Solutions
- Lecture: 7 Homework Solutions
Search This Blog
Love Babbar's C++ DSA Lecture's Solutions
Homework of Video 4 ( Solving Pattern Questions (Part-2) ) - Love babbar
Homework of Video 3 ( If-Else, While loop & Lots of Patterns (Part-1) ) - Love babbar
1. Why do we write namespace std & iostream as the program's header?
Ans. These are pre-built libraries where a code related to performing a certain task is placed So that, C++ can work effectively.
a. Using namespace std: There are a bunch of namespaces & out of them we are using std that makes the computer know that we are using cout. Basically, an identifier conflict resolver.
b. #include <iostream> : This header contains the programs of input & output functions like cout,cin etc. #include asks to include iostream
2. Guess the output :
3. Write a code that accepts char ch.
- Prints this is the lowercase or small case if lies in between 'a' - 'z'
- Prints this is uppercase if lies in between 'A' - 'Z'
- Prints this is numeric if lies in between '0' - '9'
- Fahrenheit to celsius
- Celsius to Fahrenheit
Python Mail Merge Project - Automating Recipient Writing in a Letter
- Automates the recipient writing part in the same letter.
- Recipient names are given in a separate file named invited_names.txt
- A sample letter is given in a separate file named starting_letter.txt
- Code is to be written inside main.py whose purpose is to fetch the sample letter, replace the [name] in a sample letter with recipient names & generate an individual letter following this naming convention: letter_for_{recipient_name}.txt
- The number of names given in invited_names.txt file generates a similar number of letters. Suppose, 5 names are given in invited_names.txt then, 5 letters will be generated.
Crossing the Turtle : Python Turtle Project for Beginners
- One turtle of unique color can only move forward.
- Neither left nor right. Turtle cannot even move backward.
- Turtle has to save itself from the collision with cars.
- If crosses all the cars, its level increases & along with all the car's speed!
- Random count cars & each car of random color are coming from the left & right.
- The scoreboard is maintained for every level.
How the game looks like?
Blind 75 Must Do Leetcode Python 3 Solutions
- Two Sum
- Longest Substring Without Repeating Characters
- Longest Palindromic Substring
- Container With Most Water
- 3Sum
- Remove Nth Node From End of List
- Valid Parentheses
- Merge Two Sorted Lists
- Merge k Sorted Lists
- Search in Rotated Sorted Array
- Combination Sum
- Rotate Image
- Group Anagrams
- Maximum Subarray
- Spiral Matrix
- Jump Game
- Merge Intervals
- Insert Interval
- Unique Paths
- Climbing Stairs
- Set Matrix Zeroes
- Minimum Window Substring
- Word Search
- Decode Ways
- Validate Binary Search Tree
- Same Tree
- Binary Tree Level Order Traversal
- Maximum Depth of Binary Tree
- Construct Binary Tree from Preorder and Inorder Traversal
- Best Time to Buy and Sell Stock
- Binary Tree Maximum Path Sum
- Valid Palindrome
- Longest Consecutive Sequence
- Clone Graph
- Word Break
- Linked List Cycle
- Reorder List
- Maximum Product Subarray
- Find Minimum in Rotated Sorted Array
- Reverse Bits
- Number of 1 Bits
- House Robber
- Number of Islands
- Reverse Linked List
- Course Schedule
- Implement Trie (Prefix Tree)
- Design Add and Search Words Data Structure
- Word Search II
- House Robber II
- Contains Duplicate
- Invert Binary Tree
- Kth Smallest Element in a BST
- Lowest Common Ancestor of a Binary Search Tree
- Lowest Common Ancestor of a Binary Tree
- Product of Array Except Self
- Valid Anagram
- Meeting Rooms
- Meeting Rooms II
- Graph Valid Tree
- Missing Number
- Alien Dictionary
- Encode and Decode Strings
- Find Median from Data Stream
- Longest Increasing Subsequence
- Coin Change
- Number of Connected Components in an Undirected Graph
- Counting Bits
- Top K Frequent Elements
- Sum of Two Integers
- Pacific Atlantic Water Flow
- Longest Repeating Character Replacement
- Non-overlapping Intervals
- Serialize and Deserialize BST
- Subtree of Another Tree
- Palindromic Substrings
- Longest Common Subsequence
1. Two Sum
Counting Valleys - Hackerrank Solution
Check out the counting valleys question here: Hackerrank question
The picturization of the problem:
Suppose the input is: UDDDUDUU
Then,
Answer: Valley level is 1. Because hiker stepped this way only.To solve this problem:
Initially, assumed U = 1, D = -1 & altitude=0
Then, iterated till total steps-1. Whenever altitude(height) that is sea level is 0 & the last step is 'U" I have incremented the valley by 1 (because valley level is considered only when hiker's last step is 'U" & at the sea level).
When all the elements are traversed it returned the final valley's value that's our final result.
Solution:
Sales by Match -Hackerrank solution
Check out the question here - Sales by Match
How to show code on blogger / blogspot with a copy snippet button
- Go to HTML View of blog post's editor.
- Paste the below lines inside HTML editor & replace the Your Actual Code with the desired code.
Turtle Race : Python Project for Beginners
1. 5 turtles of unique colors compete against each other.
2. User gets a chance to guess which color turtle will win the race.
3. If the user's guess is right it says you've won otherwise you lose!
Few screenshots of the game:
Doodle it: Imagine, Draw, Erase and Repeat - Python Project for Beginners
In order to create this game first step is to know a way of being able to listen to things the user does, like when a user taps a specific key on the keyboard. And the code that allows us to do this are called Event Listeners.
Go to python documentation > listen method()
It has a whole bunch of section-on-screen events, including listening to key presses or listening to a click or other things that you can listen to. So the important thing is this listen method.
Full key list for python's turtle- screen events ( Event Listeners )
Screen events
turtle.
onkey
(fun=function_name, key='Backspace')turtle.
onkeyrelease
(fun=function_name, key='Left')fun – a function with no arguments or
None
key – a string: key (e.g. “a”) or key-symbol (e.g. “space”)
.keysym | .keycode | .keysym_num | Key |
---|
Alt_L | 64 | 65513 | The left-hand alt key |
Alt_R | 113 | 65514 | The right-hand alt key |
BackSpace | 22 | 65288 | backspace |
Caps_Lock | 66 | 65549 | CapsLock |
Control_L | 37 | 65507 | The left-hand control key |
Control_R | 109 | 65508 | The right-hand control key |
Delete | 107 | 65535 | Delete |
Down | 104 | 65364 | ↓ |
End | 103 | 65367 | end |
Escape | 9 | 65307 | esc |
F1 | 67 | 65470 | Function key F1 |
F2 | 68 | 65471 | Function key F2 |
Fi | 66+i | 65469+i | Function key Fi |
F12 | 96 | 65481 | Function key F12 |
Home | 97 | 65360 | home |
Insert | 106 | 65379 | insert ( ins) |
Left | 100 | 65361 | ← |
K0 | 90 | 65438 | 0 on the keypad |
1 | 87 | 65436 | 1 on the keypad |
2 | 88 | 65433 | 2 on the keypad |
3 | 89 | 65435 | 3 on the keypad |
4 | 83 | 65430 | 4 on the keypad |
5 | 84 | 65437 | 5 on the keypad |
6 | 85 | 65432 | 6 on the keypad |
7 | 79 | 65429 | 7 on the keypad |
8 | 80 | 65431 | 8 on the keypad |
9 | 81 | 65434 | 9 on the keypad |
+ | 86 | 65451 | + on the keypad |
. | 91 | 65439 | Decimal (. ) on the keypad |
Delete | 91 | 65439 | delete on the keypad |
/ | 112 | 65455 | / on the keypad |
Down | 88 | 65433 | ↓ on the keypad |
Enter | 108 | 65421 | enter on the keypad |
Home | 79 | 65429 | home on the keypad |
Left | 83 | 65430 | ← on the keypad |
* | 63 | 65450 | × on the keypad |
Prior | 81 | 65434 | PageUp on the keypad |
Right | 85 | 65432 | → on the keypad |
- | 82 | 65453 | - on the keypad |
Up | 80 | 65431 | ↑ on the keypad |
Next | 105 | 65366 | PageDown / pg dn |
Num_Lock | 77 | 65407 | NumLock |
Pause | 110 | 65299 | pause |
Print | 111 | 65377 | PrintScrn / prt sc |
Right | 102 | 65363 | → |
Scroll_Lock | 78 | 65300 | ScrollLock |
Shift_L | 50 | 65505 | The left-hand shift key |
Shift_R | 62 | 65506 | The right-hand shift key |
Tab | 23 | 65289 | The tab key |
-
Hashing to Solutions: Two Sum Longest Substring Without Repeating Characters Longest Palindromic Substring Container With Mos...
-
Hey! Here, am on Day 02 of Angela's course. Though my heading says Day 04 which is actually done to stay in order of all the python le...
-
Exploring Data Types TechGig The question asked to check out the data type of the user input. It was quite tricky as python by default conve...