employer cover photo
employer logo
employer logo

Tata Consultancy Services

Gehört zu Tata Group

Ist dies Ihr Unternehmen?

Frage im Vorstellungsgespräch bei Tata Consultancy Services

In Coding Round, they asked about palindrome code

Antwort im Vorstellungsgespräch

Anonym

8. Nov. 2024

function isPalindrome(str) { for (let i = 0; i < str.length / 2; i++) { if (str[i] !== str[str.length - 1 - i]) { return false; // If characters don't match, it's not a palindrome } } return true; // If all characters match, it's a palindrome } console.log(isPalindrome("racecar")); // Output: true console.log(isPalindrome("hello")); // Output: false