Javascript Program for Largest Sum Contiguous Subarray
Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers that has the largest sum....
read more
Javascript Program To Merge Two Sorted Lists (In-Place)
Given two sorted lists, merge them so as to produce a combined sorted list (without using extra space).Examples:...
read more
Javascript Program For Stock Buy Sell To Maximize Profit
The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days. For example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can earned by buying on day 0, selling on day 3. Again buy on day 4 and sell on day 6. If the given array of prices is sorted in decreasing order, then profit cannot be earned at all....
read more
Javascript Program For Deleting A Linked List Node At A Given Position
Given a singly linked list and a position, delete a linked list node at the given position....
read more
Javascript Program For Finding The Middle Element Of A Given Linked List
Given a singly linked list, find the middle of the linked list. For example, if the given linked list is 1->2->3->4->5 then the output should be 3. If there are even nodes, then there would be two middle nodes, we need to print the second middle element. For example, if given linked list is 1->2->3->4->5->6 then the output should be 4....
read more
Samsung R&D Bangalore On-Campus Intern July-2019
Round 1: It was a coding round hosted on cocubes.com. There were one 3 marks question and two 5 marks question which were needed to be solved within an hour. Questions : My set was: Given an array of size n, that contains arithmetic progression, we must return the missing term. Return the count of nodes in a binary tree, whose data is equal to the sum of its children. Given a matrix representing which child likes which toy. matrix[i][j]=1 represents that child ‘i’ likes toy ‘j’. One child can get only 1 toy and one toy can be assigned to only 1 child. Find maximum number of children who can get the toy they wished. 3 marks questions were mainly based upon arrays and strings (manipulation, greedy, dynamic programming) All of the 5 marks questions were from trees, except one which was from graphs(DFS) Practice trees thoroughly. 48 students out of 200 were selected in this round....
read more
Javascript Program to Find a triplet that sum to a given value
Given an array and a value, find if there is a triplet in array whose sum is equal to the given value. If there is such a triplet present in array, then print the triplet and return true. Else return false....
read more
JavaScript program to check whether a given number is power of 2
Given a positive integer n, write a function to find if it is a power of 2 or not...
read more
Javascript Program To Find Next Greater Element
Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element on the right side of x in the array. Elements for which no greater element exist, consider the next greater element as -1....
read more
Javascript Program for Search an element in a sorted and rotated array
An element in a sorted array can be found in O(log n) time via binary search. But suppose we rotate an ascending order sorted array at some pivot unknown to you beforehand. So for instance, 1 2 3 4 5 might become 3 4 5 1 2. Devise a way to find an element in the rotated array in O(log n) time....
read more
Javascript Program to Move all zeroes to end of array
Given an array of random numbers, Push all the zero’s of a given array to the end of the array. For example, if the given arrays is {1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0}, it should be changed to {1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0}. The order of all other elements should be same. Expected time complexity is O(n) and extra space is O(1).Example:...
read more
Php Program To Find Next Greater Element
Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element on the right side of x in the array. Elements for which no greater element exist, consider the next greater element as -1....
read more