Find the Index of the First Occurrence in a String
Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = ...
3 Sum-closest
Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of ...
Zigzag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display ...
Longest Common Substring
Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new ...
Copy List with Random Pointer
A linked list of length n is given such that each node contains an additional random pointer, which could point to any ...
Implement pow(x, n)
Implement pow(x, n), which calculates x raised to the power n (i.e., xn). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: ...
Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. If there is no common ...
Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V ...
Container With Most Water
Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two ...