Add office photos
Engaged Employer

Oracle

3.7
based on 5.2k Reviews
Video summary
Filter interviews by

Cognizant Interview Questions and Answers

Updated 22 Mar 2024
Popular Designations

Q1. Modified Balanced Parentheses where a character can be matched with any other character, i.e. / with &, ! with ? and so on.

Ans.

Modified Balanced Parentheses where characters can be matched with any other character.

  • Use a stack to keep track of opening characters

  • When encountering a closing character, check if it matches the top of the stack

  • If it matches, pop from the stack, else return false

  • Continue until end of string, return true if stack is empty

Add your answer

Q2. Given an array of strings, print all the possible combinations of strings created by picking one character from each string of the array. The individual strings do not contain any duplicates. Ex: {ABC, DE} Ans...

read more
Ans.

Print all possible combinations of strings by picking one character from each string in the array.

  • Iterate through each character of the first string and combine it with each character of the second string.

  • Repeat the process for all strings in the array to get all possible combinations.

  • Use nested loops to generate combinations efficiently.

Add your answer

Q3. Given a date in string format, write a java program to return the date n days after the given date. Solve the question without using DateTimeFormatter or any similar Date parsing libraries.

Ans.

Java program to calculate date n days after given date without using Date parsing libraries.

  • Parse the input date string to extract day, month, and year components.

  • Calculate the total number of days represented by the input date.

  • Add the specified number of days to the total days calculated.

  • Convert the final total days back to day, month, and year components to get the new date.

Add your answer

Q4. Print all combinations of numbers in an array which sum up to a number k. Ex : Arr={3,1,4,5} k=5 Ans : {{1,4},{5}}

Ans.

Use backtracking to find all combinations of numbers in an array that sum up to a given number.

  • Start by sorting the array in non-decreasing order to easily identify combinations.

  • Use backtracking to recursively find all combinations that sum up to the target number.

  • Keep track of the current combination and the remaining sum as you traverse the array.

  • Add the current combination to the result when the sum equals the target number.

Add your answer
Discover Cognizant interview dos and don'ts from real experiences

Q5. Print all Pythagorean triplets within a given range.

Ans.

Print Pythagorean triplets within a given range.

  • Iterate through all possible combinations of a, b, and c within the given range

  • Check if a^2 + b^2 = c^2 for each combination

  • Print the triplets that satisfy the Pythagorean theorem

Add your answer

Q6. Check if given string has Balanced Parentheses.

Ans.

Check if a string has balanced parentheses.

  • Use a stack to keep track of opening parentheses.

  • Iterate through the string and push opening parentheses onto the stack.

  • When a closing parenthesis is encountered, pop from the stack and check if it matches the closing parenthesis.

  • If stack is empty at the end and all parentheses are matched, the string has balanced parentheses.

Add your answer

More about working at Oracle

#22 Best Mega Company - 2022
#3 Best Internet/Product Company - 2022
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Cognizant

based on 2 interviews
Interview experience
3.5
Good
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Applications Engineer Interview Questions from Similar Companies

View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter