Generate a string from an array of alphanumeric strings based on given conditions

Given an array of strings arr[] where each string is of the form “name:number” and a character T as input, the task is to generate a new string based on the following conditions:

  • In each string find the maximum digit in “number” which is less than or equal to the length of the string “name”.
  • If any such digit d is obtained, then append character at index d of the string name to the output string. Otherwise, append character T to the output string.

Examples:

Input:_ arr[] = {“Robert:36787”, “Tina:68721”, “Jo:56389”}, T = ‘X’_

Output:_ tiX_

Explanation:

For the first string “Robert:36787”: Length of “Robert” is 6. Since 6 is present in the string “36787”, 6th character of “Robert”, i.e. t is appended to the answer.

For the second string “Tina:68721”: Length of “Tina” is 4. The highest number less than equal to 4, which is present in “68721” is 2. Therefore, 2nd character of “Tina”, i.e. i is appended to the answer.

For the third string “Jo:56389”: Length of “Jo” is 2. Since no number less than equal to 2 is present in “56389”, T( = ‘X’) is appended to the answer.

Therefore, the final string after the above operations is “tiX”.

_Input: _arr[] = {“Geeks:89167”, “gfg:68795”}, T = ‘X’

Output:_ GX_

Explanation:

For the first string “Geeks:89167”, length of “Geeks” = 5 and the “89167” number has digit 1 which is less than 5.

So, the resultant string will have the character at the 1st position of the name, which is ‘G’.

For the second string “gfg:68795”, the length of “gfg” = 3, and the “68795” doesn’t have a digit less than or equals to 3.

So, the resultant string will have the character T.

Therefore, the final string after the above operations is “GX”.

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach: To solve the problem follow the steps given below:

  1. Traverse through the array of strings and split each string around “:“. The first part contains the name and second part contains the number.
  2. Store the length of the name in a variable and find the maximum digit less than or equal to the length of number.
  3. If any such digit found is found, extract the character at that index of name and append to the resultant string. Otherwise, append T to the resultant string.
  4. Print the resultant string after repeating the above operations for all the strings in the array.

Below is the implementation of the above approach:

Java

// Java program for the above approach

**import** java.io.*;

**class** GFG {

// Function to generate required string

**public** **static** String

generatePassword(String s[], **char** T)

{

// To store the result

StringBuilder result

= **new** StringBuilder();

**for** (String currentString : s) {

// Split name and number

String person[]

= currentString.split(``":"``);

String name = person[``0``];

String number = person[``1``];

**int** n = name.length();

// Stores the maximum number

// less than or equal to the

// length of name

**int** max = 0``;

**for** (``**int** i = 0``;

i < number.length(); i++) {

// Check for number by parsing

// it to integer if it is greater

// than max number so far

**int** temp = Integer.parseInt(

String.valueOf(number.charAt(i)));

**if** (temp > max && temp <= n)

max = temp;

}

// Check if no such number is

// found then we append X

// to the result.

**if** (max == 0``)

result.append(T);

// Otherwise

**else**

// Append max index

// of the name

result.append(

String.valueOf(

name.charAt(max - 1``)));

}

// Return the final string

**return** result.toString();

}

// Driver Code

**public** **static** **void**

main(String[] args)

{

String arr[] = { "Geeks:89167"``,

"gfg:68795" };

**char** T = 'X'``;

// Function Call

System.out.println(

generatePassword(arr, T));

}

}

Output:

GX

Time Complexity:_ O(N)_

Auxiliary Space:_ O(1)_

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

#arrays #searching #strings #strings

What is GEEK

Buddha Community

Generate a string from an array of alphanumeric strings based on given conditions

Generate a string from an array of alphanumeric strings based on given conditions

Given an array of strings arr[] where each string is of the form “name:number” and a character T as input, the task is to generate a new string based on the following conditions:

  • In each string find the maximum digit in “number” which is less than or equal to the length of the string “name”.
  • If any such digit d is obtained, then append character at index d of the string name to the output string. Otherwise, append character T to the output string.

Examples:

Input:_ arr[] = {“Robert:36787”, “Tina:68721”, “Jo:56389”}, T = ‘X’_

Output:_ tiX_

Explanation:

For the first string “Robert:36787”: Length of “Robert” is 6. Since 6 is present in the string “36787”, 6th character of “Robert”, i.e. t is appended to the answer.

For the second string “Tina:68721”: Length of “Tina” is 4. The highest number less than equal to 4, which is present in “68721” is 2. Therefore, 2nd character of “Tina”, i.e. i is appended to the answer.

For the third string “Jo:56389”: Length of “Jo” is 2. Since no number less than equal to 2 is present in “56389”, T( = ‘X’) is appended to the answer.

Therefore, the final string after the above operations is “tiX”.

_Input: _arr[] = {“Geeks:89167”, “gfg:68795”}, T = ‘X’

Output:_ GX_

Explanation:

For the first string “Geeks:89167”, length of “Geeks” = 5 and the “89167” number has digit 1 which is less than 5.

So, the resultant string will have the character at the 1st position of the name, which is ‘G’.

For the second string “gfg:68795”, the length of “gfg” = 3, and the “68795” doesn’t have a digit less than or equals to 3.

So, the resultant string will have the character T.

Therefore, the final string after the above operations is “GX”.

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach: To solve the problem follow the steps given below:

  1. Traverse through the array of strings and split each string around “:“. The first part contains the name and second part contains the number.
  2. Store the length of the name in a variable and find the maximum digit less than or equal to the length of number.
  3. If any such digit found is found, extract the character at that index of name and append to the resultant string. Otherwise, append T to the resultant string.
  4. Print the resultant string after repeating the above operations for all the strings in the array.

Below is the implementation of the above approach:

Java

// Java program for the above approach

**import** java.io.*;

**class** GFG {

// Function to generate required string

**public** **static** String

generatePassword(String s[], **char** T)

{

// To store the result

StringBuilder result

= **new** StringBuilder();

**for** (String currentString : s) {

// Split name and number

String person[]

= currentString.split(``":"``);

String name = person[``0``];

String number = person[``1``];

**int** n = name.length();

// Stores the maximum number

// less than or equal to the

// length of name

**int** max = 0``;

**for** (``**int** i = 0``;

i < number.length(); i++) {

// Check for number by parsing

// it to integer if it is greater

// than max number so far

**int** temp = Integer.parseInt(

String.valueOf(number.charAt(i)));

**if** (temp > max && temp <= n)

max = temp;

}

// Check if no such number is

// found then we append X

// to the result.

**if** (max == 0``)

result.append(T);

// Otherwise

**else**

// Append max index

// of the name

result.append(

String.valueOf(

name.charAt(max - 1``)));

}

// Return the final string

**return** result.toString();

}

// Driver Code

**public** **static** **void**

main(String[] args)

{

String arr[] = { "Geeks:89167"``,

"gfg:68795" };

**char** T = 'X'``;

// Function Call

System.out.println(

generatePassword(arr, T));

}

}

Output:

GX

Time Complexity:_ O(N)_

Auxiliary Space:_ O(1)_

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

#arrays #searching #strings #strings

amelia jones

1591340335

How To Take Help Of Referencing Generator

APA Referencing Generator

Many students use APA style as the key citation style in their assignment in university or college. Although, many people find it quite difficult to write the reference of the source. You ought to miss the names and dates of authors. Hence, APA referencing generator is important for reducing the burden of students. They can now feel quite easy to do the assignments on time.

The functioning of APA referencing generator

If you are struggling hard to write the APA referencing then you can take the help of APA referencing generator. It will create an excellent list. You are required to enter the information about the source. Just ensure that the text is credible and original. If you will copy references then it is a copyright violation.

You can use a referencing generator in just a click. It will generate the right references for all the sources. You are required to organize in alphabetical order. The generator will make sure that you will get good grades.

How to use APA referencing generator?

Select what is required to be cited such as journal, book, film, and others. You can choose the type of required citations list and enter all the required fields. The fields are dates, author name, title, editor name, and editions, name of publishers, chapter number, page numbers, and title of journals. You can click for reference to be generated and you will get the desired result.

Chicago Referencing Generator

Do you require the citation style? You can rely on Chicago Referencing Generator and will ensure that you will get the right citation in just a click. The generator is created to provide solutions to students to cite their research paper in Chicago style. It has proved to be the quickest and best citation generator on the market. The generator helps to sort the homework issues in few seconds. It also saves a lot of time and energy.

This tool helps researchers, professional writers, and students to manage and generate text citation essays. It will help to write Chicago style in a fast and easy way. It also provides details and directions for formatting and cites resources.

So, you must stop wasting the time and can go for Chicago Referencing Generator or APA referencing generator. These citation generators will help to solve the problem of citation issues. You can easily create citations by using endnotes and footnotes.

So, you can generate bibliographies, references, in-text citations, and title pages. These are fully automatic referencing style. You are just required to enter certain details about the citation and you will get the citation in the proper and required format.

So, if you are feeling any problem in doing assignment then you can take the help of assignment help.
If you require help for Assignment then livewebtutors is the right place for you. If you see our prices, you will observe that they are actually very affordable. Also, you can always expect a discount. Our team is capable and versatile enough to offer you exactly what you need, the best services for the prices you can afford.

read more:- Are you struggling to write a bibliography? Use Harvard referencing generator

#apa referencing generator #harvard referencing generator #chicago referencing generator #mla referencing generator #deakin referencing generator #oxford referencing generator

Madilyn  Kihn

Madilyn Kihn

1590478483

Convert String To Array Using Javascript Split Method

The easiest approach to use javascript built-in method String.split().

#javascript #javascript string #string to array #morioh #array

How To Create User-Generated Content? [A Simple Guide To Grow Your Brand]

This is image title

In this digital world, online businesses aspire to catch the attention of users in a modern and smarter way. To achieve it, they need to traverse through new approaches. Here comes to spotlight is the user-generated content or UGC.

What is user-generated content?
“ It is the content by users for users.”

Generally, the UGC is the unbiased content created and published by the brand users, social media followers, fans, and influencers that highlight their experiences with the products or services. User-generated content has superseded other marketing trends and fallen into the advertising feeds of brands. Today, more than 86 percent of companies use user-generated content as part of their marketing strategy.

In this article, we have explained the ten best ideas to create wonderful user-generated content for your brand. Let’s start without any further ado.

  1. Content From Social Media Platforms
    In the year 2020, there are 3.81 million people actively using social media around the globe. That is the reason social media content matters. Whenever users look at the content on social media that is posted by an individual, then they may be influenced by their content. Perhaps, it can be used to gain more customers or followers on your social media platforms.

This is image title

Generally, social media platforms help the brand to generate content for your users. Any user content that promotes your brand on the social media platform is the user-generated content for your business. When users create and share content on social media, they get 28% higher engagement than a standard company post.

Furthermore, you can embed your social media feed on your website also. you can use the Social Stream Designer WordPress plugin that will integrate various social media feeds from different social media platforms like Facebook, Twitter, Instagram, and many more. With this plugin, you can create a responsive wall on your WordPress website or blog in a few minutes. In addition to this, the plugin also provides more than 40 customization options to make your social stream feeds more attractive.

  1. Consumer Survey
    The customer survey provides powerful insights you need to make a better decision for your business. Moreover, it is great user-generated content that is useful for identifying unhappy consumers and those who like your product or service.

In general, surveys can be used to figure out attitudes, reactions, to evaluate customer satisfaction, estimate their opinions about different problems. Another benefit of customer surveys is that collecting outcomes can be quick. Within a few minutes, you can design and load a customer feedback survey and send it to your customers for their response. From the customer survey data, you can find your strengths, weaknesses, and get the right way to improve them to gain more customers.

  1. Run Contests
    A contest is a wonderful way to increase awareness about a product or service. Contest not just helps you to enhance the volume of user-generated content submissions, but they also help increase their quality. However, when you create a contest, it is important to keep things as simple as possible.

Additionally, it is the best way to convert your brand leads to valuable customers. The key to running a successful contest is to make sure that the reward is fair enough to motivate your participation. If the product is relevant to your participant, then chances are they were looking for it in the first place, and giving it to them for free just made you move forward ahead of your competitors. They will most likely purchase more if your product or service satisfies them.

Furthermore, running contests also improve the customer-brand relationship and allows more people to participate in it. It will drive a real result for your online business. If your WordPress website has Google Analytics, then track contest page visits, referral traffic, other website traffic, and many more.

  1. Review And Testimonials
    Customer reviews are a popular user-generated content strategy. One research found that around 68% of customers must see at least four reviews before trusting a brand. And, approximately 40 percent of consumers will stop using a business after they read negative reviews.

The business reviews help your consumers to make a buying decision without any hurdle. While you may decide to remove all the negative reviews about your business, those are still valuable user-generated content that provides honest opinions from real users. Customer feedback can help you with what needs to be improved with your products or services. This thing is not only beneficial to the next customer but your business as a whole.

This is image title

Reviews are powerful as the platform they are built upon. That is the reason it is important to gather reviews from third-party review websites like Google review, Facebook review, and many more, or direct reviews on a website. It is the most vital form of feedback that can help brands grow globally and motivate audience interactions.

However, you can also invite your customers to share their unique or successful testimonials. It is a great way to display your products while inspiring others to purchase from your website.

  1. Video Content
    A great video is a video that is enjoyed by visitors. These different types of videos, such as 360-degree product videos, product demo videos, animated videos, and corporate videos. The Facebook study has demonstrated that users spend 3x more time watching live videos than normal videos. With the live video, you can get more user-created content.

Moreover, Instagram videos create around 3x more comments rather than Instagram photo posts. Instagram videos generally include short videos posted by real customers on Instagram with the tag of a particular brand. Brands can repost the stories as user-generated content to engage more audiences and create valid promotions on social media.

Similarly, imagine you are browsing a YouTube channel, and you look at a brand being supported by some authentic customers through a small video. So, it will catch your attention. With the videos, they can tell you about the branded products, especially the unboxing videos displaying all the inside products and how well it works for them. That type of video is enough to create a sense of desire in the consumers.

Continue Reading

#how to get more user generated content #importance of user generated content #user generated content #user generated content advantages #user generated content best practices #user generated content pros and cons

Joseph  Murray

Joseph Murray

1621615800

String Array In Java: Java String Array With Coding Examples

In Java, Array refers to a crucial data structure used to collect and store multiple data types from primitive to user-defined. String array is the array of various objects where each of its elements is a string. Users can perform several operations on these components, like adding a component, sorting, joining, searching, splitting, etc.

Introduction To A String Array In Java

It is possible to have an array with strings in Java as its derived elements. This means that users can define ‘String Array’ as an array that holds a certain number of string values or strings. In other words, it refers to a structure that is widely used in Java for having the string value. For instance, even the number of arguments of the prime function in Java refers to a string array.

#software development #array in java #java #string array