# Introduction to NOT Operator

The Bitwise NOT operator evaluates the binary representation of the value of a single input. If the bit contains 1, the output will be 0 for that bit location. If the bit contains 0, the output will be 1.

## Introduction

This lesson introduces the tilde '~' character. This is applied to a single operand and inverts each input operand's bit.

## Sketch

This is the same as the NOT gate we studied in the digital electronics chapter shown below:

## What is the Bitwise NOT operator?

The Bitwise NOT operator is denoted by `~`.

The Bitwise operator evaluates the binary representation of the value of a single input. The Bitwise complement of the binary representation is determined for each bit in the binary representation. If the bit contains 1, the output will be 0 for that bit location. If the bit contains 0, the output will be 1.

## Syntax

``~a``
• 1 => yields 0
• 0 => yields 1

a ~a
1 0
0 1

## Truth table

a ~a
True False
False True

Let’s see some of the Bitwise `NOT` operator examples in the next lesson.

Bit ManipulationData Structures and Algorithms

Gopi is an engineering leader with 12+ of experience in full-stack development—a specialist in Java technology stack. He worked for multiple startups, the European govt, and FAANG in India and Europe.

Members Public

## Leetcode 217: Contains Duplicate

This question marks the first problem when working on duplicate data, either integers or strings etc. Companies that have asked this in their coding interview are Amazon, Apple, Netflix, Google, Microsoft, Adobe, Facebook, and many more top tech companies. Problem statement Given an integer array nums, return true if any

Members Public

## Leetcode 121: Best Time To Buy and Sell Stock

The Best time to buy and sell stock problem is a classic problem that can be solved using the Greedy approach. This is one of the most popular questions asked in such interviews. Companies that have asked this in their coding interview are Facebook, Amazon, Apple, Netflix, Google, Microsoft, Adobe,

Members Public

## Bit Manipulation Course Overview

Overview In this course, you will learn how to solve problems using bit manipulation, a powerful technique that can be used to optimize your algorithmic and problem-solving skills. This is one of the most important/critical topics when someone starts preparing for coding interviews for FAANG companies. To kick things