f

Newton school DSA 2 mock interview question || Newton School assignments solution || Newton school coding Question

 







Nihal shaikh 

1) Write a program to check the given linked list is palindrome or not ? 

2) Problem Statement: Given a set of strings, find the longest common prefix. 

Examples: 

Input: {"geeksforgeeks", "geeks", "geek", "geezer"} 

Output: "gee" 

Input: {"apple", "ape", "april"} 

Output: "ap" 

 

 

Manish shaw 

Generate 2n Valid Parentesis 

Longest common prefix  

Move all occurrance of the given key to the end of the linked list 

Sorting given character Array using Linked List 

 

Mecharte Lavnyasai  

 

left most repeated character  

Merge two shortest Linked list 

sum of minimum and maximum in subarrays 

Next larger element (Stack) 

 

Manish shaw 

 

1.Print All Possible Valid Combinations Of Parenthesis of Given ‘N’ 

2. Given an array arr[] containing N lowercase English alphabets, the task is to sort this array arr[] using a linked list. 

 

 

Ashish Sarkar (ashishsarkar94) 

 

You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional child pointer. This child pointer may or may not point to a separate 

doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure as shown in the example below. 

 

Given the head of the first level of the list, flatten the list so that all the nodes appear in a single-level, doubly linked list. Let curr be a node with a child list. 

The nodes in the child list should appear after curr and before curr.next in the flattened list. 

 

Return the head of the flattened list. The nodes in the list must have all of their child pointers set to null. 

 

Input: head = [1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12] 

Output: [1,2,3,7,8,11,12,9,10,4,5,6] 

 

Input: head = [1,2,null,3] 

Output: [1,3,2] 

 

1 =>2 

| <= 

V 

3 

/* 

// Definition for a Node. 

class Node { 

public int val; 

public Node prev; 

public Node next; 

public Node child; 

}; 

*/ 

 

Tarun pandey 

1. Palindromic LinkedList 

2. Contains Duplicate values in the LinkedList 

 

Prabhat Khare 

 

1. You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.  
Merge all the linked-lists into one sorted linked-list and return it.  
Input: lists = [[1,4,5],[1,3,4],[2,6]]  
Output: [1,1,2,3,4,4,5,6]  
Explanation: The linked-lists are:  
[  
1->4->5,  
1->3->4,  
2->6  
]  
merging them into one sorted list:  
1->1->2->3->4->4->5->6  
eg.  
[[-1,5,11],[0,6,10],[-1,0,6,10]]  
[  
-1 -> 5 -> 11  
0 ->6->10  
-1,06,10  
]  
 
2. You have to delete ‘Kth’ node from end of list.  
Write a function to return resultant list.  
Eg.  
1 -> 2-> 3 ->4 -> 5 ->null k=2  
Result : 1-> 2 ->3->5 ->null  
Constraint : You dont know length of linked list. 

 

Versa 

 

1) Given a string S, find the length of the longest substring without repeating characters 

2) Generate binary numbers between 1 to `n` using a queue 

 

1) Remove all the vowel from the given String. 

input "what is your name ? " 

output "wht s yr nm ?" 

2) Find the common character from given stringArray . 

input {"apple", "orange"} 

output 'a', 'e' 

 

Ashim kaushal 

 

Next Greatest Element/Next Larger Element 

Add two linkedlist 

 

anirban paul 

 

delete the middle of the linked list if odd delete middle if even delete 2 middle nodes 

 

Delete even nodes in circular linkedlist (https://my.newtonschool.co/playground/code/rcl0f5w7231h/) 

Implement queue using stack 

 

Manikantha S 

 

1) What are the different types of Strings in java  

2) What are the different access modifiers in java  

3) Implement a Stack using Queue  

4) A palindrome is a string that remains the same if reversed. 

write a program to find a string whose at least one of the substrings is a palindrome (Unable to complete due to some technical issue) 

 

 

 

Kishlay Kumar 

 

do 1st two perfectly next 2 if 1st two not solved,,ok  

Code 1 - Given the head of a linked list, remove the nth node from the end of the list and return its head. 
 
Input: head = [1,3,4,7,1,2,6] 
Output: [1,3,4,1,2,6] 
 
Code 2 - You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. 
 
Return the max sliding window. 
 
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3 
Output: [3,3,5,5,6,7] 
 
Code 3 - The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. 
 
You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2. 
 
For each 0 <= i < nums1.length, find the index j such that nums1[i] == nums2[j] and determine the next greater element of nums2[j] in nums2. If there is no next greater element, then the answer for this query is -1. 
 
Return an array ans of length nums1.length such that ans[i] is the next greater element as described above. 
 
Input: nums1 = [4,1,2], nums2 = [1,3,4,2] 
Output: [-1,3,-1] 
 
Code - 4 Given an array arr[ ] of size N having distinct elements, the task is to find the next greater element for each element of the array in order of their appearance in the array. 
Next greater element of an element in the array is the nearest element on the right which is greater than the current element. 
If there does not exist next greater of current element, then next greater element for current element is -1. For example, next greater of the last element is always -1. 
 
Input:  
N = 4, arr[] = [1 3 2 4] 
Output: 
3 4 4 -1 

 

 

Shubham Bajpai 

 

Suppose you are given two sorted linked list. Merge two linked lists in sorted order, assume no repetition of numbers(duplicate numbers) in linked list: 
Eg:  
I/p 1->2->4->5 3->6->8->9->10 
o/p 1->2->3->4->5->6->8->9->10 

Reverse a linked list  
Eg: I/p 1->2->3->4->5 O/p: 5->4->3->2->1 
 

 

 

Manjunath 

 

Find the Factorial of Given Number- solved  
 
implement a Singly linked list with Add and Display Operation  

 

 

Ronak Goliya 

 

Add 1 to a number represented as linked list 

 

Ravi prakash 

 

Implement a Stack using LinkedList 
 
- Write a code to check given string is Palindrome or not using Stack 

Soumya pandith 

 

Various operations of stack 

Different types of linked list, explain them 

difference between peek and pop operation 

what is a double ended queue, priority queue 

Real life applications of stack 

String output based question. 

Coding Question - 

Given a string, find the minimum number of characters to be inserted to convert it to palindrome. 

Insert elements into a linked list and print them. 

 

 

Utkarsh jain 

Application of Stack, Queue 

Difference between Doubly linked list and circular lined list 

 

 

Dilip Rathod 

 

wap to find string is palindrome or not 

wap to find no. of vowels and consonents 

wap to find middle element of linkedlist 

 

 

Shubham madheysia 

 

 

Write a function detectAndRemoveLoop() that checks whether a given Linked List contains a loop and if loop is present then removes the loop and returns true. If the list doesn’t contain a loop then it returns false.  
Example:  
Input: 1 ⇒ 2 ⇒3 ⇒ 4 ⇒ 5 ⇒ 6 ⇒ 3  
Output: 1 ⇒ 2 ⇒3 ⇒ 4 ⇒ 5 ⇒ 6 ⇒null  
Explanation: 6 is connected to 3 which makes 3 ⇒4 ⇒5 ⇒6 in loop 

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.  
Input: s = "(()"  
Output: 2  
Explanation: The longest valid parentheses substring is "()".  
Input: s = "(()(()()"  
Output: 4  
Explanation: The longest valid parentheses substring is "()()".  
Input: s = ""  
Output: 0 

Given a Singly Circular Linked List, starting from the first node delete all odd position nodes in it.  
Note: Linked list is considered to have 1-based indexing. That is, the first element in the linked list is at position 1.  
Examples:  
Input : 99 ⇒ 11 ⇒ 22 ⇒ 33  
Output : 11 ⇒ 33  
Input : 90 ⇒ 10 ⇒ 20 ⇒ 30  
Output : 10 ⇒ 30 

 

Tarun pandey 

 

Length of the Longest Alphabetical Continuous Substring 

Remove loop from the linkedlist 

 

Shivam singh 

 

Find the duplicates with user input in liked list 

reverse the linked list by taking user input 

 

 

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.