Pointers in C++ are symbolic representations of addresses. They enable programs to simulate call-by-reference as well as to create and manipulate dynamic data structures. By using pointers we can get the first character of the string, which is the starting address of the string. As shown below, the given string can be accessed and printed through the pointers.@Algorithm_s1 #cpp
In this example, we will first slice the string up to the character that we want to delete and then concatenate the remaining string next from the deleted character. #python @Algorithm_s1
Exchange Values Using Tuples
One of the popular tricks in Python is to exchange values without creating a temporary variable. The method is applicable for any number of variables.
The right side of a sequence assignment statement allows any iterable objects to be specified. The main thing is that the number of elements on the left is equal to the number of elements on the right. This assignment also applies to complex nested structures.
@Algorithm_s1 #python
One of the popular tricks in Python is to exchange values without creating a temporary variable. The method is applicable for any number of variables.
The right side of a sequence assignment statement allows any iterable objects to be specified. The main thing is that the number of elements on the left is equal to the number of elements on the right. This assignment also applies to complex nested structures.
@Algorithm_s1 #python
List inclusions
Perhaps somewhere before this you may have already heard the concept of “list comprehensions”. This is a way to fit a for loop, an if block, and an assignment into one line.
Let's start with the simplest example. Let's say we need to square all the elements of the list again.
Yes, this code is definitely shorter than the previous one, but it's still ugly. At first glance, it's hard to tell what the map function does (it takes a function and a list as arguments, and applies the function to each element of the list). Plus we are forced to define a function, which looks pretty messy.
But it turns out that you can write simpler and clearer
@Algorithm_s1 #python
Perhaps somewhere before this you may have already heard the concept of “list comprehensions”. This is a way to fit a for loop, an if block, and an assignment into one line.
Let's start with the simplest example. Let's say we need to square all the elements of the list again.
Yes, this code is definitely shorter than the previous one, but it's still ugly. At first glance, it's hard to tell what the map function does (it takes a function and a list as arguments, and applies the function to each element of the list). Plus we are forced to define a function, which looks pretty messy.
But it turns out that you can write simpler and clearer
@Algorithm_s1 #python