Creative programming is a programming method that aims to create something expressive and visually appealing, rather than something purely functional. This type of programming method is used to create live artwork, graphical simulations and visualization algorithms. There are many tools and libraries for creative or visual programming, of which the processing is the most widely used….
Given a list of elements, remove alternating successive duplicates of the elements. Input: test_list = [5, 5, 5, 5, 6, 6]Output: [5, 5, 6]Description: Alternate OCC. One of 5 and 6 was removed.Input: test_list = [5, 5, 5, 5]Output: [5, 5]Description: Alternate OCC. 5 were deleted. Method: Use loop + remove() A combination of the above features…
We have given an array of n different numbers. The task is to sort all even and odd numbers in ascending order. The modified array should contain the even-numbered numbers of all sorts, followed by the odd-numbered numbers of the reverse sorts. Note that the first element is considered an even placement because it has…
Given a string, recursively removes adjacent duplicate characters from the string. The output string should not contain any adjacent duplicates. See the example below. Example: Input: azxxzyOutput: ayfirst reduce “azxxzy” to “azzy”. The string “azzy” contains duplicates, so it is further simplified to “ay”.Input: geeksforgeegOutput: gksforThe first “geeksforgeeg” is simplified to “gksforgg”. The string “gksforgg”…
Like binary search, jump search is a search algorithm used to sort arrays. The basic idea is to check for fewer elements (than a linear search), move forward in fixed steps, or skip certain elements instead of searching for all elements. For example, let’s say we have an array arr[] of size n and a block (to…
Construct a binary tree from a given binary search tree so that it traverses the output sorted data in order of levels. Example: Input: Output: 1 2 3 Input: Output: 1 2 3 4 5 Method: Here’s an implementation of the above method: C ++ Java Python3 C# The output is as follows:
Given a string s. Let K be the maximum number of partitions possible for a given string, each beginning with a different character. The task is to find a way to split the strings into multiple K partitions (non-empty) so that each partition starts with a different character. Example: First, we need to find the value of…
Title: Design a data structure SpecialStack that supports all stack operations, such as push(), pop(), isEmpty(), isFull() and additional operations getMin(), which should return the smallest element in the SpecialStack. All of these operations of the SpecialStack must be O(1). To implement SpecialStack, you should only use standard stack data structures, and not other data structures such as arrays,…
Given two integers X and Y, find the smallest number X with the sum of the numbers, which is strictly greater than Y. Example: Input: X = 18, Y = 99Output: 189 Description: 189 is the smallest number greater than 99, and the sum of digits = 18.Input: X = 12, Y = 72Output: 75Description:…
Given two positive integers L and R, the task is to calculate the elements in the range [L, R] whose main factors are only 2 and 3. Example: Input: L = 1, R = 10Output: 6Description: 2 = 2 3 = 3 4 = 2 * 2 6 = 2 * 3 8 = 2…