import sys
from collections import deque
# Define a class for tree nodes
class TreeNode:
def __init__(self, value):
self.val = value
self.left = None
self.right = None
# Insert a value into the Binary Search Tree (BST)
def insert_bst(root, value):
if root is None:
return TreeNode(value) # Create a new node if the current node is None
if value < root.val:
root.left = insert_bst(root.left, value) # Insert into the left subtree if the value is smaller
else:
root.right = insert_bst(root.right, value) # Insert into the right subtree if the value is larger
return root
# Find the k-th smallest element in the BST using in-order traversal
def kth_smallest(root, k):
stack = []
current = root
count = 0
while True:
# Traverse the left subtree
while current is not None:
stack.append(current)
current = current.left
if not stack:
return None # If the stack is empty, there are fewer than k elements
# Pop the node from the stack
current = stack.pop()
count += 1
# If the count matches k, return the current node's value
if count == k:
return current.val
# Traverse the right subtree
current = current.right
# Main function to read input and output the k-th smallest element
def main():
# Read the number of nodes and the value of k
n, k = map(int, sys.stdin.readline().strip().split())
# Read the values to insert into the BST
values = list(map(int, sys.stdin.readline().strip().split()))
root = None
# Insert all values into the BST
for value in values:
root = insert_bst(root, value)
# Find and print the k-th smallest element
result = kth_smallest(root, k)
print(result)
# Entry point of the script
if __name__ == "__main__":
main()
K-th smallest element // starium
5/ 5
Stay tuned
@CODE_ALPHIX
Test accomplished
Please open Telegram to view this post
VIEW IN TELEGRAM
๐13๐3โค1๐ฅ1๐1๐1๐ซก1
IBM
Both Coding ๐ฏ๐ฑ
Test accomplished๐
DM for any placement help
-@mrtrueliving_ix
-@mrtrueliving_ix
-@mrtrueliving_ix
All placement help available
#IBM #coding #Done
Both Coding ๐ฏ
Test accomplished
DM for any placement help
-@mrtrueliving_ix
-@mrtrueliving_ix
-@mrtrueliving_ix
All placement help available
#IBM #coding #Done
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Valuefy-On campus
With remote access {clg lab}
Test accomplished
All 3 codes are done๐ฃ ๐ฏโค๏ธ
Leading with rank-1 ๐๐
All placement help available
-@mrtrueliving_ix
-@mrtrueliving_ix
#Valuefy #coding #Done
With remote access {clg lab}
Test accomplished
All 3 codes are done
Leading with rank-1 ๐๐
All placement help available
-@mrtrueliving_ix
-@mrtrueliving_ix
#Valuefy #coding #Done
Please open Telegram to view this post
VIEW IN TELEGRAM
๐1
Starium
All 5/5 codes are done โ ๐ฏ
100/100 ๐๐
All placement help available
-@mrtryeliving_ix
All 5/5 codes are done โ ๐ฏ
100/100 ๐
All placement help available
-@mrtryeliving_ix
Please open Telegram to view this post
VIEW IN TELEGRAM
HELP AVAILABLE IBM CIC{6PM}
https://t.me/code_alphix/3118
NIVIDA {6PM}
DM-@MRTRUELIVING_IX
๐ฏ TEST CLEARANCE
Please open Telegram to view this post
VIEW IN TELEGRAM
CISCO - Software Engineer
All 3/3 coding are doneโถ๏ธ ๐
Test accomplished๐ฅณ
All placement help available
-@mrtrueliving_ix
-@mrtrueliving_ix
-@mrtrueliving_ix
#CISCO #Software_Engineer #coding #Successfully
All 3/3 coding are done
Test accomplished
All placement help available
-@mrtrueliving_ix
-@mrtrueliving_ix
-@mrtrueliving_ix
#CISCO #Software_Engineer #coding #Successfully
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
๐1๐1
Please open Telegram to view this post
VIEW IN TELEGRAM
https://app.joinsuperset.com/students/jobprofiles/e1752f96-2780-4797-b0af-f343b582a62d/outline
Pwc - 2025 batch
Pwc - 2025 batch
Joinsuperset
Superset :: University Recruiting Platform
Superset is a unified web-based solution, that transforms the cumbersome process of placements at institutes into a clutter-free, effortless and smooth experience.
๐1
Apply Link ๐๏ธ
https://assessment.hackerearth.com/challenges/new/hiring/namma-yatri-software-development-engineer-hiring-challenge-2024/
Must Apply and don't Miss this opportunity
Please open Telegram to view this post
VIEW IN TELEGRAM
HackerEarth
Namma Yatri Software Development Engineer Hiring Challenge 2024
Challenge Overview
Weโre thrilled to announce that Namma Yatri is kicking off an exciting hiring challenge on HackerEarth! As a trailblazer in the mobility sector, Namma Yatri is reshaping the way people commute by empowering drivers and enhancing the passengerโฆ
Weโre thrilled to announce that Namma Yatri is kicking off an exciting hiring challenge on HackerEarth! As a trailblazer in the mobility sector, Namma Yatri is reshaping the way people commute by empowering drivers and enhancing the passengerโฆ
All placement help available
๐คช Auto desk
๐คช Accenture {on || Off}
๐คช UBER
๐คช COGNIZANT
๐คช micron
๐คช Oracle
๐คช Visa
๐คช Deloitte
๐คช Zeta
๐คช Namma Yatri
Any other OA help available
๐ฏ Test Clearance ๐
With remote access { High success rate}๐
-@mrtrueliving_ix
-@mrtrueliving_ix
Any other OA help available
With remote access { High success rate}
-@mrtrueliving_ix
-@mrtrueliving_ix
Please open Telegram to view this post
VIEW IN TELEGRAM
InfoObjects-ONcampus
All MCQ are done 50/50 ๐๐ฃ
Test accomplishedโ๏ธ
All placement help available
-@mrtrueliving_ix
-@mrtrueliving_ix
#InfoObjects #Aptitude #ONCampus
All MCQ are done 50/50 ๐
Test accomplished
All placement help available
-@mrtrueliving_ix
-@mrtrueliving_ix
#InfoObjects #Aptitude #ONCampus
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM