leetcode 88:- Merge Sorted Array solution in java

Merge Sorted Array solution in java You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned…

leetcode solution of problem “Two Sum”

Two Sum Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. This problem is…

leetcode solution of problem 53 in java

Maximum Subarray Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. The problem is taken from the below mentioned link:- Leetcode Problem Approach:- In most of the case this kind of problems…

Leetcode solution of problem 217 in java

Contains Duplicate Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. The above problem is taken from the below mentioned link:- Leetcode Problem Approach:- Use of HashSet data structure will solve the problem. Here Set is chosen as it…

Leetcode 1290 solution in java

Convert Binary Number in a Linked List to Integer Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. Return the decimal value of the number in the linked list. The problem is…