std::none_of() in C++
Table of Contents Overviewstd::none_of() – Syntax, Parameters and Return ValueExamples using std::none_of()Example 1 – using an array of integers with std::none_of()Example 2 – using a string with std::none_of()Time Complexity discussionSuggested Reading std::none_of() is a built-in function under the header . none_of() This C++ method returns true if all the elements in the range[start, end) returns false for a certain condition(a predicate).…
https://thecodingbot.com/stdnone_of-in-c/
Table of Contents Overviewstd::none_of() – Syntax, Parameters and Return ValueExamples using std::none_of()Example 1 – using an array of integers with std::none_of()Example 2 – using a string with std::none_of()Time Complexity discussionSuggested Reading std::none_of() is a built-in function under the header . none_of() This C++ method returns true if all the elements in the range[start, end) returns false for a certain condition(a predicate).…
https://thecodingbot.com/stdnone_of-in-c/
The Coding Bot
std::none_of() in C++ - The Coding Bot
In this post, we'll discuss built-in std::none_of() in C++. The post has examples for better understanding and also discusses about time complexity of the function.
Python’s len() on a dictionary
len() is a built-in function in python which returns the number of items in an object. It can be used with a sequence(list, tuple, string etc) or a collection (like dictionary, set etc). However, this tutorial shall only focus its use with a dictionary. For complete tutorial on built-in len(), visit: Python’s built-in len() method…
https://thecodingbot.com/pythons-len-on-a-dictionary/
len() is a built-in function in python which returns the number of items in an object. It can be used with a sequence(list, tuple, string etc) or a collection (like dictionary, set etc). However, this tutorial shall only focus its use with a dictionary. For complete tutorial on built-in len(), visit: Python’s built-in len() method…
https://thecodingbot.com/pythons-len-on-a-dictionary/
The Coding Bot
Python's dictionary len() method - The Coding Bot
In this article, we'll show you the use of python's len() function on a simple dictionary as well as on a nested dictionary.
Python’s list() method on a dictionary
list() is a built-in python method, and also a constructor. When an iterable is passed to the method, it converts the iterable to a list. This tutorial will only focus on the use of list() function with a dictionary. For a detailed tutorial on the function list(), visit: Python’s list() with examples ( A detailed…
https://thecodingbot.com/pythons-list-method-on-a-dictionary/
list() is a built-in python method, and also a constructor. When an iterable is passed to the method, it converts the iterable to a list. This tutorial will only focus on the use of list() function with a dictionary. For a detailed tutorial on the function list(), visit: Python’s list() with examples ( A detailed…
https://thecodingbot.com/pythons-list-method-on-a-dictionary/
The Coding Bot
Python's list() method on a dictionary - The Coding Bot
In this article, we'll show you the use of python's list() function on a simple dictionary as well as on a nested dictionary.
dictionary[‘key’]: Fetching the value for a particular key in a dictionary in Python
A dictionary is basically a set of key:value pairs with a condition that no two keys are the same. Each key-value pair in the dictionary is separated by a comma. Let’s see an example of a dictionary in python, dictionary = {'apple': 2,'banana' : 5, 'carrot' : 4} Here, apple, banana and carrot are the keys; while…
https://thecodingbot.com/fetching-the-value-for-a-particular-key-in-a-dictionary-in-python/
A dictionary is basically a set of key:value pairs with a condition that no two keys are the same. Each key-value pair in the dictionary is separated by a comma. Let’s see an example of a dictionary in python, dictionary = {'apple': 2,'banana' : 5, 'carrot' : 4} Here, apple, banana and carrot are the keys; while…
https://thecodingbot.com/fetching-the-value-for-a-particular-key-in-a-dictionary-in-python/
The Coding Bot
dictionary['key']: Fetching the value for a particular key in a dictionary in Python - The Coding Bot
In this article, we'll show you the different ways you can access the value associated with a key in python dictionary.
del d[key]: Removing the key from Python dictionary
This tutorial only focuses on the use of del keyword to delete the key from a dictionary. There are other ways too which we shall discuss in a seperate post. del is a keyword in Python which is used to delete the Objects. Since everything in Python is Object, it can be used to delete the…
https://thecodingbot.com/del-dkey-removing-the-key-from-python-dictionary/
This tutorial only focuses on the use of del keyword to delete the key from a dictionary. There are other ways too which we shall discuss in a seperate post. del is a keyword in Python which is used to delete the Objects. Since everything in Python is Object, it can be used to delete the…
https://thecodingbot.com/del-dkey-removing-the-key-from-python-dictionary/
The Coding Bot
del d[key]: Removing the key from Python dictionary - The Coding Bot
In this post, we'll show you how you can delete a key from python dictionary using python's del keyword and what possible error it raises.
Check if a given key already exists in a Python dictionary (4 ways)
Table of Contents OverviewMethod 1 – Using in keywordMethod 2 – Finding the key in dict.keys()Method 3 – Using try and except block to check if the key is present in the dictionary or not.Method 4 – Iterating over dict.items() and finding the key existenceWhich is the fastest way to find key among all? What…
https://thecodingbot.com/check-if-a-given-key-already-exists-in-a-python-dictionary-4-ways/
Table of Contents OverviewMethod 1 – Using in keywordMethod 2 – Finding the key in dict.keys()Method 3 – Using try and except block to check if the key is present in the dictionary or not.Method 4 – Iterating over dict.items() and finding the key existenceWhich is the fastest way to find key among all? What…
https://thecodingbot.com/check-if-a-given-key-already-exists-in-a-python-dictionary-4-ways/
The Coding Bot
Check if a given key already exists in a Python dictionary (4 ways) - The Coding Bot
In this blog post, we'll show you different ways how you can check if the key exists in the dictionary or not.
Python dictionary items() method
Table of Contents Overviewdictionary.items() – Syntax, Parameters and Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.items() Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is…
https://thecodingbot.com/python-dictionary-items-method/
Table of Contents Overviewdictionary.items() – Syntax, Parameters and Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.items() Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is…
https://thecodingbot.com/python-dictionary-items-method/
The Coding Bot
Python dictionary items() method - The Coding Bot
In this article, we'll discuss python dictionary's built-in items() method. We will also see what dictionary view objects are in detail..
dictionary.clear() method in Python
Say you have a dictionary, and now, you want to get rid of its element, you want it clean. How would you do that? There are many utility methods for Python dictionary and dictionary.clear() does exactly what we want. In this post, we will discuss about clear() method for dictionaries in Python. After that, we’ll…
https://thecodingbot.com/dictionary-clear-method-in-python/
Say you have a dictionary, and now, you want to get rid of its element, you want it clean. How would you do that? There are many utility methods for Python dictionary and dictionary.clear() does exactly what we want. In this post, we will discuss about clear() method for dictionaries in Python. After that, we’ll…
https://thecodingbot.com/dictionary-clear-method-in-python/
The Coding Bot
dictionary.clear() method in Python - The Coding Bot
In this tutorial, we'll see how we can clear a dictionary in python using the built-in clear() method with some examples
Python dictionary’s get() method
Table of Contents Overviewdictionary.get() – Syntax, Parameters and the Return ValueExamples using get()Comparison between get() and subscript notation dictionary[key]Time Complexity analysis of get() Suggested Reading In this tutorial, we’ll talk about get() method from Python’s dictionary data structure. It is probably the most used method from the dictionary class. Today, we’ll see its syntax, the…
https://thecodingbot.com/python-dictionarys-get-method/
Table of Contents Overviewdictionary.get() – Syntax, Parameters and the Return ValueExamples using get()Comparison between get() and subscript notation dictionary[key]Time Complexity analysis of get() Suggested Reading In this tutorial, we’ll talk about get() method from Python’s dictionary data structure. It is probably the most used method from the dictionary class. Today, we’ll see its syntax, the…
https://thecodingbot.com/python-dictionarys-get-method/
The Coding Bot
Python dictionary's get() method - The Coding Bot
In this article, we'll talk about python dictionary's get() method. We'll see some examples and analyse the time complexity of the function
Python dictionary’s fromkeys() method
Table of Contents Overviewdict.fromkeys() – Syntax, Parameters and the Return ValueExamples using dict.fromkeys()Example using dict.fromkeys() with a list, set, dictionary, tuple and a stringExample using dict.fromkeys() with an iterator objectImportant observationsSuggested Reading Python’s fromkeys() is a classmethod belongs to Python’s dict class. It is used to construct a new dictionary from an iterable. The keys…
https://thecodingbot.com/python-dictionarys-fromkeys-method/
Table of Contents Overviewdict.fromkeys() – Syntax, Parameters and the Return ValueExamples using dict.fromkeys()Example using dict.fromkeys() with a list, set, dictionary, tuple and a stringExample using dict.fromkeys() with an iterator objectImportant observationsSuggested Reading Python’s fromkeys() is a classmethod belongs to Python’s dict class. It is used to construct a new dictionary from an iterable. The keys…
https://thecodingbot.com/python-dictionarys-fromkeys-method/
The Coding Bot
Python dictionary's fromkeys() method - The Coding Bot
In this article, we'll discuss python's built-in fromkeys() method, we'll also see some examples to concrete our concepts regarding the same.
Python dictionary’s keys() method with examples
Table of Contents Overviewdictionary.keys() – Syntax, Parameters and the Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.keys()Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is initialized. It…
https://thecodingbot.com/python-dictionarys-keys-method-with-examples/
Table of Contents Overviewdictionary.keys() – Syntax, Parameters and the Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.keys()Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is initialized. It…
https://thecodingbot.com/python-dictionarys-keys-method-with-examples/
The Coding Bot
Python dictionary's keys() method with examples - The Coding Bot
In this article, we'll discuss python dictionary's built-in keys() method. We will also see what dictionary view objects are,in detail..
Time Complexity analysis of Python dictionary’s get() method
We have already discussed Python dictionary’s get() method in great detail here(you might want to go and check that first). In this tutorial, we shall only focus on the runtime cost of the method. Before moving forward, let’s briefly see whatget() function does. get() dictionary.get(key,default_value) gets the value associated with the key key in the dictionary. If the key isn’t present…
https://thecodingbot.com/time-complexity-analysis-of-python-dictionarys-get-method/
We have already discussed Python dictionary’s get() method in great detail here(you might want to go and check that first). In this tutorial, we shall only focus on the runtime cost of the method. Before moving forward, let’s briefly see whatget() function does. get() dictionary.get(key,default_value) gets the value associated with the key key in the dictionary. If the key isn’t present…
https://thecodingbot.com/time-complexity-analysis-of-python-dictionarys-get-method/
The Coding Bot
Time Complexity analysis of Python dictionary's get() method - The Coding Bot
In this tutorial, we'll discuss the time complexity of dictionary's get() method. We'll also what is a collision in a Hashmap with example
LeetCode – 387. First Unique Character in a String
Problem Statement: Given a string, find the first non-repeating character in it and return its index. If it doesn’t exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contains only lowercase letters. Solution Probably the best approach to solve this problem is by traversing the string and using a…
https://thecodingbot.com/leetcode-387-first-unique-character-in-a-string/
Problem Statement: Given a string, find the first non-repeating character in it and return its index. If it doesn’t exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contains only lowercase letters. Solution Probably the best approach to solve this problem is by traversing the string and using a…
https://thecodingbot.com/leetcode-387-first-unique-character-in-a-string/
The Coding Bot
LeetCode - 387. First Unique Character in a String - The Coding Bot
In this tutorial, we will see how we can solve leetcode problem 387 - "First Unique Character in a String"
LeetCode – 69. Sqrt(x)
Problem Statement Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Example 1: Input: 4 Output: 2 ----------- Example 2: Input: 8 Output: 2 Explanation: The…
https://thecodingbot.com/leetcode-69-sqrtx/
Problem Statement Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Example 1: Input: 4 Output: 2 ----------- Example 2: Input: 8 Output: 2 Explanation: The…
https://thecodingbot.com/leetcode-69-sqrtx/
The Coding Bot
LeetCode - 69. Sqrt(x) - The Coding Bot
In this tutorial, we'll see how we can solve leetcode problem 69 sqrt(x). This problem can be solved using binary search algorithm
Find and Replace in Vim/Vi (covering different scenarios)
Table of Contents Find and replace in the whole file Command and ExplanationFind and replace in certain line in the fileCommand and Explanation Find and replace the words in a range of linesCommand and Explanation Find and Replace is a pretty useful feature which can save your time a lot. Vim/Vi comes with the find and…
https://thecodingbot.com/find-and-replace-in-vim-vi-covering-different-scenarios/
Table of Contents Find and replace in the whole file Command and ExplanationFind and replace in certain line in the fileCommand and Explanation Find and replace the words in a range of linesCommand and Explanation Find and Replace is a pretty useful feature which can save your time a lot. Vim/Vi comes with the find and…
https://thecodingbot.com/find-and-replace-in-vim-vi-covering-different-scenarios/
The Coding Bot
Find and Replace in Vim/Vi (covering different scenarios) - The Coding Bot
In this tutorial, we will see how we can find and replace in Vim/Vi editor. This is a complete tutorial covering different scenarios.
LeetCode – 7. Reverse Integer
Problem Statement Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that…
https://thecodingbot.com/leetcode-7-reverse-integer/
Problem Statement Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that…
https://thecodingbot.com/leetcode-7-reverse-integer/
The Coding Bot
LeetCode - 7. Reverse Integer - The Coding Bot
In this article, we will see how we can solve famous interview problem from leetcode. The problem name is "LeetCode - 7. Reverse Integer"
LeetCode – 26. Remove Duplicates from Sorted Array
Problem Statement Given a sorted array nums, remove the duplicates in-place such that each element appears only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Example 1: Given nums = [1,1,2], Your function should return…
https://thecodingbot.com/leetcode-26-remove-duplicates-from-sorted-array/
Problem Statement Given a sorted array nums, remove the duplicates in-place such that each element appears only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Example 1: Given nums = [1,1,2], Your function should return…
https://thecodingbot.com/leetcode-26-remove-duplicates-from-sorted-array/
The Coding Bot
LeetCode - 26. Remove Duplicates from Sorted Array - The Coding Bot
In this article, we'll see how we can solve "LeetCode 26 Remove Duplicates from Sorted Array". We'll also see the time-space complexity of the problem.
Python dictionary’s values() method with examples
Table of Contents Overviewdictionary.values() – Syntax, Parameters and the Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.values()Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is initialized. It…
https://thecodingbot.com/python-dictionarys-values-method-with-examples/
Table of Contents Overviewdictionary.values() – Syntax, Parameters and the Return ValueDiscussion on dictionary view objectsAn example demonstrating view objects in PythonExamples using dictionary.values()Suggested Reading What is a dictionary in Python? A dictionary in Python is a collection which is unordered, mutable and indexed. Mutable here means that the dictionary can be changed/updated after it is initialized. It…
https://thecodingbot.com/python-dictionarys-values-method-with-examples/
The Coding Bot
Python dictionary’s values() method with examples - The Coding Bot
In this article, we'll discuss python dictionary's built-in values() method. We will also see what dictionary view objects are,in detail..
Python dictionary’s pop() method with examples
Table of Contents Overviewdictionary.pop() – Syntax, Parameters and Return ValueExamples using pop()Example 1 – When the key is present in the dictionaryExample 2 – When the key is not present but the default is passedExample 3 – When the key is not present and no default is passedReplicating pop() with try and catch block and…
https://thecodingbot.com/python-dictionarys-pop-method-with-examples/
Table of Contents Overviewdictionary.pop() – Syntax, Parameters and Return ValueExamples using pop()Example 1 – When the key is present in the dictionaryExample 2 – When the key is not present but the default is passedExample 3 – When the key is not present and no default is passedReplicating pop() with try and catch block and…
https://thecodingbot.com/python-dictionarys-pop-method-with-examples/
The Coding Bot
Python dictionary's pop() method with examples - The Coding Bot
In this article, we'll discuss python dictionary's built-in pop() method, we'll also see some examples demonstrating the usage of the function
Python dictionary’s popitem() method with examples
Table of Contents Overviewpopitem() – Syntax, Parameters and the Return ValueExamples using popitem() methodExample 1 – Completely deleting all the elements from the dictionary using popitem()Example 2 – When the dictionary is empty or run out of elementsSuggested Reading Sometimes we need to iterate through a dictionary in Python and delete its items sequentially. To…
https://thecodingbot.com/python-dictionarys-popitem-method-with-examples/
Table of Contents Overviewpopitem() – Syntax, Parameters and the Return ValueExamples using popitem() methodExample 1 – Completely deleting all the elements from the dictionary using popitem()Example 2 – When the dictionary is empty or run out of elementsSuggested Reading Sometimes we need to iterate through a dictionary in Python and delete its items sequentially. To…
https://thecodingbot.com/python-dictionarys-popitem-method-with-examples/
The Coding Bot
Python dictionary's popitem() method with examples - The Coding Bot
In this article, we'll discuss python dictionary's built-in popitem() method with examples. It is used to remove elements from dictionary in LIFO order.