Archive for September 2019
Problem Statment Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions. Example Input: head = 1->4->3->2->5->2, x . . . Read more
Problem Statement Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Input: haystack = “hello”, needle = “ll” Output: 2 Solution
Problem Statement Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be . . . Read more
Problem StatementGiven a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Given nums = [0,0,1,1,1,2,2,3,3,4], Your function . . . Read more
Problem Statement You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any . . . Read more
Problem Statement Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example Given nums = [2, 7, 11, 15], . . . Read more