Strings Programs in JAVA
51 / 59
Each date is in the form ddmmmyyyy where
dd is the set {0-31}
mmm is in the set {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec)
yyyy is four digits.
Example
dates = {'01 Mar 2017';'03 Feb 2017';'15 Jan 1998']
The array dates sort to ['15 Jan 1998';'03 Feb 2017';'01 Mar 2017';]
Input : {'01 Mar 2017';'03 Feb 2017';'15 Jan 1998']
Output :
Tags:SAP Labs
52 / 59
Input : NA
Output : NA
Tags:SAP Labs
53 / 59
Hint:An anagram of a string is another string that contains same characters, only the order of characters can be different.
Example: "abcd" and "dabc" are anagram of each other.
Input : LISTEN
Output :
Tags:SAP Labs
54 / 59
Input : NA
Output : NA
Tags:SAP Labs
55 / 59
A password manager wants to create a new password using two strings given by the user, then combined to create a harder-to-guess combination. Given two strings, interleave the characters of the strings to create a new string. Beginning with an empty string, alternately append a character from string a and from string b. If one of the strings is exhausted before the other, append the remaining letters from the other string all at once. The result is the new password.
Example:
If a = saplab and b = q4interview ,the result is sqa4pilnatberview.
Function Description
Complete the function newPassword in the editor below
newPassword has the following parameter(s):
string a the first string
string b the second string
Input : a = saplab
b = q4interview
Output :
Tags:SAP Labs
56 / 59
A subsequence of a string is obtained by deleting zero or more characters from the string while maintaining order. Given a string, generate an array of all subsequences sorted alphabetically ascending, omitting the empty string.
Example
For example, the subsequences of string s = "xyz", not including the empty string, are "x", "xy", "xz", "xyz", "y", "yz", and "z"
Function Description:
Complete the function builds sequences in the editor below.
buildSubsequences has the following parameter(s)
str s: the string to process
Returns:
str[]: An array of strings comprising all the subsequences of the given string sorted alphabetically, ascending.
constraints:
1 < length of s <16
s is a string of distinct lowercase English alphabetic letter ascii[a-z]
Input : NA
Output : NA
Tags:SAP Labs
57 / 59
There are two strings, s, and t.
Perform two operationss with the string s:
1. Working from left-to-right delete each occurrence of t in s until there are no more occurrences of t. Count each deletion.
2. working from right-to-left delete each occurrence of t in s until there are no more occurrences of t. Count each deletion.
When that is done, return the greater of the two counts; deletion left-to-right or deletions right-to-left.
Example
s = 'bcbbc'
t = 'b'
From left to right:
Remove th first occurrence t = 'b' from"
Input : NA
Output : NA
Tags:SAP Labs
58 / 59
Input : arr[] = {10, 50, 12, 100}
Output : (10, 12)
The closest elements are 10 and 12
Input : arr[] = {5, 4, 3, 2}
Output :
Tags:SAP Labs
59 / 59
If multiple characters occur with the same highest frequency then return "0".
Input : Input1: abcdd
Output :
Tags:TCS NQT Nagarro Wipro NLTH
You can practice the basics and standard Strings programs given at page 6, asked at freshers or experienced level job interview. Practice our hand-picked page 6 Strings coding interview questions asked in coding round of various it companies and exams. You can programed these given question in any language, you can post your answer and same time you can review other users answer. It is always recommanded to write your own Strings coding questions answer first and then refer others answers. At this page 6 we have covers all the Strings coding questions in 2020 and previously asked in their Interview round or coding rounds.
Top Kudos Contributor
Trending Programming Qs.
- Given a string, say sentence=" this is crazy and fun" and a list, say ...
- Write a program to print next to the last word of a sentence.
- Write a program to generate a simple pattern. 1 12 123 1234 123 ...
- There are many cars parked in the parking lot. The parking is a straig...
- Write fibonacci series program. INPUT: 10 term OUTPUT: 0 1 1 2 3 5...
- Write a program to print next to the last word of a sentence.
Last Month Contributor
- Write a program to print next to the last word of a sentence.
- Write a program to convert uppercase to lower case and vice versa of a...
- Given a string, say sentence=" this is crazy and fun" and a list, say ...
- Write a program to remove the vowels from the input string.
- Write fibonacci series program. INPUT: 10 term OUTPUT: 0 1 1 2 3 5...