Problem Statement
Refer to the problem statement given @ Hackerrank Super Reduced String
Code
This problem is solved through Recursion but I will be working on a better solution soon. However this code pass all the…
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
label
neighbors
OJ’s undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each node, and , as a separator for…
#
,
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from…
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists, begin to intersect at node c1.
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space?
Binary Search Tree Implementation
public class Node { private int key; private Node left; private Node right; private Node parent;
public Node(int key){this.key = key;}
public void setLeft(Node…
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] has the largest sum = 6.