Uploaded by Paris Eduardo Palacios Hernández

Java/Spring Boot Interview Study Guide: Palindrome & Data Structures

advertisement
Java / Spring boot Study guide for interview SemSenior software
engineer
Palindrome
Verify if a given String is a palindrome.
Using for and arrays to swap the values:
Using StringBuilder:
Using recursion: the core idea is to compare first and last index and then pass recursively a
substring without those values and so on until base cases.
Count number of bad pairs
you are given with a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i < j and j - i
!= nums[j] - nums[i]
return the total number of bad pairs in nums.
Example: Input: nums = [4,1,3,3]
Output: 5
Explanation: (0, 1) is a bad pair since 1 - 0 != 1-4;
(0,2) is bad pair since 2-0 != 3-4
so on with other values in total there are 5 bad pairs. so we return 5.
Proposed solution:
Create our own StringBuilder:
Create our own ArrayList:
Create our own HashMap:
Download