Largest Positive Integer That Exists With Its Negative

Problem Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array. Return the positive integer k. If there is no such integer, return -1. Examples Example 1: Input: nums = [-1,2,-3,3] Output: 3 Explanation: 3 is the only valid k we can find in the array. ...

Reverse Prefix of Word

2Sum Problem Problem Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing. For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be "dcbaefd". Return the resulting string. ...

2Sum Problem

Problem You are given an array of n integers and a target sum T. The goal is to determine whether or not there are two numbers x, y in A with x+y=T. OR Given an array of integers, find two numbers such that they add up to a specific target number. Variant: Return the indices instead of the elements in array. Example Example 1: ...

Remove duplicates from Sorted List 2

Problem Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well. Examples Example 1: Input: head = [1,2,3,3,4,4,5] Output: [1,2,5] ...

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