Jump to content

Recommended Posts

Posted

ah blog nadheeeeee

 

 

:P requirement naku sarigga ardam kala but cheppe lepedham tondargaa

 

 

Mr.Jambalheart seniormost java prof vachesadu!!

  • Replies 38
  • Created
  • Last Reply

Top Posters In This Topic

  • tejak123

    12

  • god father

    8

  • TOM_BHAYYA

    7

  • fake_Bezawada

    4

Popular Days

Top Posters In This Topic

Posted

Mr.Jambalheart seniormost java prof vachesadu!!

..
 
HAmmayya.. Pmed bezawada baaabai
Posted

seee

 

 here you not iterate for checking

 

 public List<String> evaluate(ArrayList<String> list,Text text) {
 String product= text.toString();
 
 List<String> productList = new ArrayList<String>(); 
 for(String str : list)
 {
 if(!(product.equals(str)))
 {
productList.add(str);
 }
 }
return productList;
 
  }
 
========================
 
 public List<String> evaluate(ArrayList<String> list,Text text) {
 String product= text.toString();
   if(list.contains(product)){
  list.remove(list..IndexOf(product));
// now return the original list thats it
}
 
 
// you can optimise this code like this
 List<String> productList = new ArrayList<String>(); 
 for(String str : list)
 {
 if(!(product.equals(str)))
 {
productList.add(str);
 }
 }
return productList;
 
  }
 
Posted

class 1:

 

package com.mkyong.stock.model;
 
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
 
public class SampleTest {
 
 public static void main(String[] args) {
 
 List<String> namesList = new ArrayList<String>();
 namesList.add("TOM_BHAYYA");
 namesList.add("lollilolli");
 namesList.add("TOM_BHAYYA");
 namesList.add("lollilolli");
 namesList.add("afdb");
 namesList.add("TOM_BHAYYA");
 namesList.add("afdb");
 namesList.add("afdb");
 namesList.add("tfdb");
 namesList.add("afdb");
 namesList.add("lollilolli");
 
 
 List<String> resultList = evaluate(namesList);
 
 for(String str : resultList)
 {
 System.out.println(str);
 }
 
 
 
 Map<String, Integer> occurrences = new HashMap<String, Integer>();
 
 for ( String word : resultList ) {
    Integer oldCount = occurrences.get(word);
    if ( oldCount == null ) {
       oldCount = 0;
    }
    occurrences.put(word, oldCount + 1);
 }
 
 System.out.println(occurrences);
 
 ValueComparator bvc =  new ValueComparator(occurrences);
 TreeMap<String,Integer> sorted_map = new TreeMap<String,Integer>(bvc);
 
       sorted_map.putAll(occurrences);
       
       System.out.println(sorted_map);
 }
 
 public static  List<String> evaluate(List<String> list) {
 String product= "TOM_BHAYYA";
 
 List<String> productList = new ArrayList<String>(); 
 for(String str : list)
 {
 if(!(product.equals(str)))
 {
 productList.add(str);
 //System.out.println(str);
 }
 }
return productList;
 
}
 
}
 
 
 
class 2:
 
 
package com.mkyong.stock.model;
 
import java.util.Comparator;
import java.util.Map;
 
class ValueComparator implements Comparator<String> {
 
    Map<String, Integer> base;
    public ValueComparator(Map<String, Integer> occurrences) {
        this.base = occurrences;
    }
 
    // Note: this comparator imposes orderings that are inconsistent with equals.    
    public int compare(String a, String b) {
        if (base.get(a) >= base.get(b)) {
            return -1;
        } else {
            return 1;
        } // returning 0 would merge keys
    }
}
 
 
 
 
change the package names according to your project..  

 

Posted

vuncle  inka simplify cheyochhemo pedda ga think cheyale..

 

googling chesina vaaitho naa lappy lo run chesi paste chesa..

 

inka simplified kaavalante time dhorkinappudu chestha

Posted

vuncle  inka simplify cheyochhemo pedda ga think cheyale..

 

googling chesina vaaitho naa lappy lo run chesi paste chesa..

 

inka simplified kaavalante time dhorkinappudu chestha

 

 

bhayya nuvvu rasinde nenu anukunna kani vadiki kavalsindi 5 times kante a list lo words repeat avva koodadu for suppose aithe danini delete chesi vere dantlo pettali

Posted

bhayya nuvvu rasinde nenu anukunna kani vadiki kavalsindi 5 times kante a list lo words repeat avva koodadu for suppose aithe danini delete chesi vere dantlo pettali.////

 

 

if there are only 5 distinct elements in array . i need those five ...

.but if there are 10 elements repetitive.. i need top 5... 

 

 

 

 

 
Posted
 for ( String word : resultList ) {
    Integer oldCount = occurrences.get(word);
    if ( oldCount == null ) {
       oldCount = 0;
    }
  else if (count<5){
}else if(count>=5){
  resultlist.remove();
}
    occurrences.put(word, oldCount + 1);
 }
 
i guess this will solve your problem
Posted

let hime give some sample inputs 

 

appudu to bhayyiah and VD cheseyachu easy ga

Posted


bhayya nuvvu rasinde nenu anukunna kani vadiki kavalsindi 5 times kante a list lo words repeat avva koodadu for suppose aithe danini delete chesi vere dantlo pettali.////



if there are only 5 distinct elements in array . i need those five ...

.but if there are 10 elements repetitive.. i need top 5...





Vuncle .. Nenu neeku ichhindhi okasaari run chey

Elaagu ordered tree map undhi kaabatti neeku istamochinattu print chesko kadha ..

Delete 6 to rest of the values from the tree map if you want
Posted

Vuncle .. Nenu neeku ichhindhi okasaari run chey

Elaagu ordered tree map undhi kaabatti neeku istamochinattu print chesko kadha .. 

Delete 6 to rest of the values from the tree map if you want ..//

 

 

correct bhaiya... motham anni elements count tho vachina kuda.. treee kabatti.. we can play as we like.. 

 

 

 

Posted

Vuncle .. Nenu neeku ichhindhi okasaari run chey

Elaagu ordered tree map undhi kaabatti neeku istamochinattu print chesko kadha ..

Delete 6 to rest of the values from the tree map if you want ..//


correct bhaiya... motham anni elements count tho vachina kuda.. treee kabatti.. we can play as we like..


K k aithe done a issue?
Posted

K k aithe done a issue? .//

 

I cant run now.. jar create chesi.. CLI lo run cheyyali. .. that too with hadooop libraries add chesi cheyyali... i think i got the logic right..  if i am struck i have you people to pull me out.. thanks bhaiya's... first job antey inthey emo

Posted

K k aithe done a issue? .//

 

I cant run now.. jar create chesi.. CLI lo run cheyyali. .. that too with hadooop libraries add chesi cheyyali... i think i got the logic right..  if i am struck i have you people to pull me out.. thanks bhaiya's... first job antey inthey emo

nee local eclipse lo run cheyadaniki jar endhuku maaan..

 

okasaari neeku kaavalsina pattern osthundho raatledho eclipse lo run chey kadha telusthadhi.. 

 

 

note; quote chey bro posts ki nuvvu atla 3/// petti reply isthe confuse authunna..

Posted

use these sample code as stand alone testing stubs then once they work you can put them in the working environment

×
×
  • Create New...