Sonal Singhswapping-value-of-2-variables-a-and-b.hashnode.dev·Oct 16, 2024Swapping the value of a and b without using a temporary variable.The most obvious way to perform a swap is to use a temporary C variable; however, there are also some unique methods to swap values without using any extra memory. In this article, we will see two different and efficient ways to swap without a tempor...2 likes·89 readsC
Akash Dasakashdas7781.hashnode.dev·Sep 17, 2024Mastering Bit-Manipulation : A Beginner to expert guide with simple ExamplesBit Manipulation is one of the most efficient way to optimize your code . Whether you are working with algorithms ,Cryptography or System level programming ,understanding of bit-manipulation can give you a significant performance boost .In this guide...binary bits
Filip Melkafilipmelka.hashnode.dev·Jul 11, 2024Solving a Code Wars Challenge with the Reduce Method and a Bitwise OperatorWhile solving problems on Code Wars, I came across an interesting problem called Find the Odd Int. It seemed simple at first, but one particular solution fascinated me so much that I decided to write about it. The problem Here's what the problem asks...Codewars
Vineeth Chivukulavineethchivukula.hashnode.dev·Jul 6, 2024Solving Missing NumberTo see the question, click here. Naive Approach The idea is to sort the array and then compare the index with the number present at that index. // TC: O(nlogn) // SC: O(1) import java.util.Arrays; class MissingNumber { public int missingNumber(...cyclic-sort
Vineeth Chivukulavineethchivukula.hashnode.dev·Jun 29, 2024Solving Single NumberTo see the question, click here. Naive Approach To find the single element, we can first sort the array and then check for the single element. This approach works because each element appears twice except for one, and when the array is sorted, these ...single number
Vineeth Chivukulavineethchivukula.hashnode.dev·Jun 25, 2024Understanding Bitwise XORThe Bitwise XOR operation is a fundamental concept in computer science and is used in various algorithms and data structures to solve problems efficiently. The XOR operation is performed on individual bits of two numbers and returns 1 if the bits are...XOR
Gulshan Kumarperfinsights.hashnode.dev·Jun 3, 2024Find the XOR of Numbers Which Appear TwiceYou are given an array nums, where each number in the array appears either once or twice. Return the bitwise XOR of all the numbers that appear twice in the array, or 0 if no number appears twice. LeetCode Problem - 3158 import java.util.HashMap; imp...Java SolutionJava
Pradeep Chodisettibackend.engg.wiki·Jan 18, 2024XOR using Tries - Part 2Before you go on, please make sure you have read Part 1. Great! Let’s talk about the next usecase. Problem Given an array of integers, find the maximum xor subarray. Or simply,Given a1, a2, ....., an, find i and j , i <= j, such that ai xor ai+1 xor ...algorithms
Pradeep Chodisettibackend.engg.wiki·Jan 18, 2024XOR using Tries - Part 1Trie Trie can store information about keys/numbers/strings compactly in a tree. Tries consists of nodes, where each node stores a character/bit. We can insert new strings/numbers accordingly. Storing numbers in trie We can store numbers in trie using...algorithms
Chetan Dattachetan77.hashnode.dev·Oct 26, 2023Subarray with given XORProblem Link Given an array of integers A and an integer B Find the total number of subarrays having bitwise XOR of all elements equal to B. Brute force approach An easy approach is to find all the subarrays, perform XOR operations to compare them wi...Leetcodeleetcode