Non-Decreasing Array in Python

Arnab Chakraborty
Updated on 27-Apr-2020 09:12:39

1K+ Views

Suppose we have an array with n integers, our task is to check whether it could become nondecreasing by modifying at most one element. We can define an array is non-decreasing if it satisfies this rule: array[i] 0if arr[i - 1] > arr[i + 1], then arr[i + 1] := arr[i]return trueExample (Python)Let us see the following implementation to get a better understanding − Live Democlass Solution(object):    def checkPossibility(self, nums):       if len(nums) nums[i+1]:             if ans:                return False           ... Read More

Play with Chips in C++

Arnab Chakraborty
Updated on 27-Apr-2020 09:10:14

403 Views

Suppose there are some chips, the i-th chip is at present at position chips[i]. We can perform any of the two following types of operations any many numbers of times as we want (possibly zero) on any chip −Move the i-th chip by 2 units to the left side or to the right side with a cost of 0.Move the i-th chip by 1 unit to the left side or to the right side with a cost of 1.Initially, there can be two or more chips. We have to return the minimum cost needed to move all the chips to ... Read More

Maximize Sum of Array After K Negations in Python

Arnab Chakraborty
Updated on 27-Apr-2020 09:06:24

357 Views

Suppose we have an array A of integers, we have to modify the array in the following way −We can choose an i and replace the A[i] with -A[i], and we will repeat this process K times. We have to return the largest possible sum of the array after changing it in this way.So, if the array A = [4, 2, 3], and K = 1, then the output will be 5. So choose indices 1, the array will become [4, -2, 3]To solve this, we will follow these steps −Sort the array Afor i in range 0 to length ... Read More

Merge Two Binary Trees in C++

Arnab Chakraborty
Updated on 27-Apr-2020 08:59:01

742 Views

Suppose we have two binary trees and consider that when we put one of them to cover the other, some nodes of the two trees are overlapped while the others are overlapping. We have to merge them into a new binary tree. The merge rule is like that if two nodes are overlapping, then sum node values up as the new value of the merged node. Otherwise, the non-empty node will be used as the node of the new tree.So if the trees are −Then the output will be −To solve this, we will follow these steps −The method is ... Read More

Shortest Unsorted Continuous Subarray in Python

Arnab Chakraborty
Updated on 27-Apr-2020 08:55:20

320 Views

Suppose we have an integer array, we need to find one continuous subarray such that, if we only sort that subarray in ascending order, then the whole array will be sorted too. We need to find the shortest such subarray and output its length. So if the array is [2, 6, 4, 8, 10, 9, 15], then the output will be 5. The array will be [6, 4, 8, 10, 9]To solve this, we will follow these steps −res := sort the nums as an arrayans := 0set r as a linked listfor i in range 0 to the length ... Read More

Palindrome Linked List in Python

Arnab Chakraborty
Updated on 27-Apr-2020 08:50:56

2K+ Views

Suppose we have a linked list. We have to check whether the list elements are forming a palindrome or not. So if the list element is like [1, 2, 3, 2, 1], then this is a palindrome.To solve this, we will follow these steps −fast := head, slow := head, rev := None and flag := 1if the head is empty, then return truewhile fast and next of fast is availableif next of the next of fast is available, then set flag := 0 and break the loopfast := next of the next of fasttemp := slow, slow := next ... Read More

What is Bluetooth?

Moumita
Updated on 27-Apr-2020 07:18:51

7K+ Views

Bluetooth is a network technology that connects mobile devices wirelessly over a short-range to form a personal area network (PAN). They use short-wavelength, ultra-high frequency (UHF) radio waves within the range 2.400 to 2.485 GHz, instead of RS-232 data cables of wired PANs.Features of BluetoothBluetooth technology was released in 1999 as Bluetooth 1.0, by Special Interest Group (SIG) who continues to manage it.It was initially standardized as IEEE 802.15.1.Mobile computing devices and accessories are connected wirelessly by Bluetooth using short-range, low-power, inexpensive radios.UHF radio waves within the range of 2.400 to 2.485 GHz are using for data communications.A PAN or ... Read More

802.16 MAC Sublayer Protocol

Moumita
Updated on 27-Apr-2020 07:17:49

3K+ Views

The IEEE 802.16 is a set of standards defining the specifications for wireless broadband technology. It has been commercialized as Worldwide Interoperability for Microwave Access (WiMAX) that is responsible for the delivery of last-mile wireless broadband access. It lays down the standards for both physical layer as well as medium access control (MAC) layer for WiMAX.The IEEE 802.16 MAC sublayer is a part of the data link layer. The data link layer of WiMAX is divided into three sublayers as follows −Security sublayer − This is the bottommost layer and is concerned with the security and privacy of the wireless ... Read More

802.16 MAC Sublayer Frame Structure

Moumita
Updated on 27-Apr-2020 07:15:44

3K+ Views

The IEEE 802.16 set of standards lays down the specifications for wireless broadband technology. It has been commercialized as Worldwide Interoperability for Microwave Access (WiMAX) that is responsible for the delivery of last-mile wireless broadband access.The IEEE 802.16 MAC sublayer is the most important sublayer and concerned with channel management. It has been designed for connection-oriented channel management for point-to-multipoint (PMP) broadband services.The frame format of a generic MAC frame is shown below −The fields are −EC − A single-bit field indicating whether the payload is encrypted.Type − A 6-bit field identifying frame type.CI − A single-bit field denoting the ... Read More

What is Piconet?

Moumita
Updated on 27-Apr-2020 07:13:52

7K+ Views

A piconet is a small Bluetooth network that connects mobile devices wirelessly over a short range of 10m radius, using ultra-high frequency (UHF) radio waves, to form a personal area network (PAN).A piconet can be formed by at most 8 stations, one of which is the master node and the rest slave nodes. Thus, it can accommodate a maximum of 7 slaves. The master node is the primary station that manages the small network. The slave stations are secondary stations that are synchronized with the primary station.Communication can take place between a master node and a slave node in either ... Read More

Advertisements