Two Sum Less Than K Problem

Problem Given an array A of integers and integer K, return the maximum S such that there exists i < j with A[i] + A[j] = S and S < K. If no i, j exist satisfying this equation, return -1. Examples Example 1: Input: A = [34,23,1,24,75,33,54,8], K = 60 Output: 58 Explanation: We can use 34 and 24 to sum 58 which is less than 60. ...

Valid Palindrome Problem

Problem Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Palindrome Definition Examples Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: "amanaplanacanalpanama" is a palindrome. Example 2: Input: s = "race a car" Output: false Explanation: "raceacar" is not a palindrome. ...

Remove duplicates from Sorted Array 1

Problem Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Note that even though we want you to return the new length, make sure to change the original array as well in place. ...

Remove Element Problem

Problem Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k elements of nums should hold the final result. It does not matter what you leave beyond the first k elements. ...

Reverse Linked List Problem

Problem Reverse a linked list. Follow up 1 - Do it in-place and in one-pass. Follow up 2 - Can you do it with only 2 pointers. Examples For example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL ...

Valid Palindrome 2 Problem

Problem Given a string s, return true if the s can be palindrome after deleting at most one character from it. Examples Example 1: Input: s = "aba" Output: true Example 2: Input: s = "abca" Output: true Explanation: You could delete the character 'c'. ...

Check if given array is Palindrome OR Not

Check if Given Array is Palindrome OR Not Problem Given an array, the task is to determine whether an array is a palindrome or not. Examples Example 1: Input: arr[] = {3, 6, 0, 6, 3} Output: true Example 2: Input: arr[] = {1, 2, 3, 4, 5} Output: false ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy