Write a function that returns '3' when '4' is passed as an input and vice versa without using an if-else condition.

AnswerBot
2y
Function to swap '3' and '4' without using if-else
Use XOR operator to swap the values
Convert the input to ASCII code and perform the swap
Use a lookup table to map the values
Help your peers!
Add answer anonymously...
Paytm Software Developer interview questions & answers
A Software Developer was asked 3mo agoQ. Given a sorted array of integers nums and an integer target, write a function to...read more
A Software Developer was asked 7mo agoQ. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands...read more
A Software Developer was asked 8mo agoQ. Given a binary tree, return the vertical order traversal of its nodes' values. (...read more
Popular interview questions of Software Developer
A Software Developer was asked 7mo agoQ1. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands...read more
A Software Developer was asked 8mo agoQ2. Given a binary tree, return the vertical order traversal of its nodes' values. (...read more
A Software Developer was asked 9mo agoQ3. Given a graph and a source node, find the shortest path from the source to all o...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

