Merge K Sorted Lists in Python

Arnab Chakraborty
Updated on 26-May-2020 11:30:07

995 Views

Suppose we have some lists, these are sorted. We have to merge these lists into one list. To solve this, we will use the heap data structure. So if the lists are [1, 4, 5], [1, 3, 4], [2, 6], then the final list will be [1, 1, 2, 3, 4, 4, 5, 6].To solve this, we will follow these steps −make one heapfor each linked list l in lists −if is in not 0, then insert I into a heapres := null and res_next := nullDo one infinite loop −temp := min of heapif heap has no element, then ... Read More

Regular Expression Matching in Python

Arnab Chakraborty
Updated on 26-May-2020 11:20:39

557 Views

Suppose we have an input string s and another input string p. Here s is the main string and p is the pattern. We have to define one method, that can match patterns in the string. So we have to implement this for a regular expression, that supports ‘.’ And ‘*’.Dot ‘.’ Matches any single characterStar ‘*’ Matches zero or more of the preceding element.So for example, if the input is like s = “aa” and p = “a.”, then it will be true, for the same input string, if the patter is “.*”, then it will be true.To solve ... Read More

Median of Two Sorted Arrays in C++

Arnab Chakraborty
Updated on 26-May-2020 11:17:49

500 Views

Suppose we have two arrays; these arrays are sorted. So we have to find the median of these two arrays. So if the arrays are like [1,5,8] and [2,3,6,9], then the answer will be 5.To solve this, we will follow these steps −Define a function findMedianSortedArrays, this will take nums1 and nums2 arraysif size of nums1 > size of nums2, then,Call the function return findMedianSortedArrays(nums2, nums1)x := size of nums1, y := size of nums2low := 0, high := xtotalLength := x + ywhile low

Create Left to Right Slide Animation in Android Using Kotlin

Azhar
Updated on 26-May-2020 08:49:35

825 Views

This example demonstrates how to Create Left to Right slide animation in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                 Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.transition.Slide import android.transition.TransitionManager import android.view.Gravity import android.view.View import android.widget.Button import android.widget.RelativeLayout import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var btnSlideLeft: Button    lateinit var btnSlideRight: Button    lateinit var ... Read More

Send Intent to Browser to Open Specific URL using Kotlin

Azhar
Updated on 26-May-2020 08:46:02

2K+ Views

This example demonstrates how to Send an Intent to browser to open specific URL using KotlinStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.content.Intent import android.net.Uri import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"    }   ... Read More

Validate Email Address in Android Using Kotlin

Azhar
Updated on 26-May-2020 08:42:57

3K+ Views

This example demonstrates how to validate an e-mail address in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml             Step 3 − Add the following code to src/MainActivity.kt import android.import android.os.Bundle import android.view.View import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private lateinit var editText: EditText    private lateinit var email: String    private val emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\.+[a-z]+"    override fun onCreate(savedInstanceState: ... Read More

Get Value of Edit Text Field in Android Using Kotlin

Azhar
Updated on 26-May-2020 08:40:00

7K+ Views

This example demonstrates how to  get Value of a Edit Text field in Android using Kotlin?Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                 Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.Button import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var button: Button    lateinit var editText: EditText    lateinit var string: String    lateinit var textView: ... Read More

Find Latitude and Longitude from Address on Android Using Kotlin

Azhar
Updated on 26-May-2020 08:36:28

913 Views

This example demonstrates how to find the latitude and longitude from address on Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                 Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.os.Handler import android.os.Message import android.widget.Button import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private lateinit var addressButton: Button    private lateinit var textViewAddress: TextView    lateinit var ... Read More

Add a Footer in Android ListView Using Kotlin

Azhar
Updated on 26-May-2020 08:30:04

505 Views

This example demonstrates how to add a footer in Android ListView using KotlinStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.view.ViewGroup import android.widget.ArrayAdapter import android.widget.ListView import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() {    private lateinit var listView: ListView    var country = arrayOf(       "India",       "Australia",       "South Africa", ... Read More

Subscript and Superscript a String in Android using Kotlin

Azhar
Updated on 26-May-2020 08:26:22

492 Views

This example demonstrates how to Subscript and Superscript a String in Android using KotlinStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.text.SpannableStringBuilder import android.text.Spanned import android.text.style.RelativeSizeSpan import android.text.style.SubscriptSpan import android.text.style.SuperscriptSpan import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    private lateinit var strText: String    lateinit var spannableStringBuilder: SpannableStringBuilder    override fun ... Read More

Advertisements